Current time: 11-26-2024, 04:11 PM Hello There, Guest! (LoginRegister)


Announcement
We have the biggest collection of MyBB Plugins here on the Net. We have currently 175+ MyBB Exclusive Plugins, 80+ MyBB Compatible MyCodes and 16+ MyBB 1.4.x Themes (Some are still under construction...) Thus, we provide you the largest MyBB Stuff on the net including tutorials. Stay with us, you will find out some more to come.
Now you can easily create your own buttons set for MyBB! Click here to have a look...
*** You cannot do your registration behind any Proxies anymore! ***
Welcome Guest[3.149.231.122], connected from
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sliding door buttons technique revisited...
12-19-2009, 06:07 PM (This post was last modified: 12-22-2009 11:20 AM by exdiogene.)
Post: #1
Sliding door buttons technique revisited...

This tutorial is to help new theme designers and coders to know the "sliding door" technique to create and display many buttons of different width, with only one image.

I hope that this tutorial will help MyBB people to understand a little bit more how they can decrease the downloading time of a webpage having many single images buttons compare to only one image. Here are some facts :

A webpage having 10 menu buttons and 10 other buttons elsewere in the page will take approximately 9 seconds to download with a 56Kbauds modem if the average size of the images are 3KBytes.
( 20 buttons * 3KB = 60KB )
( 56Kbauds modem transfer at an average of 3KBytes/second )
( 60KB / 3KB = 20 seconds )

With this technique one single 3KB image is needed for all buttons taking less than 1 second even with the extra text needed to create all buttons.

Please note that you must also include a javascript portion for the browsers not able to handle the features actually available with FireFox for the button movements on actuation.

The second biggest advantage of this technique compared to the graphic buttons is that it is very easy to create new buttons with different text on the fly, not needing any graphic editors.

So we need first an image suitable for all our buttons, i have choosen a wood stick for this tutorial. As you can see i created a 800 pixels image to suit any portion of the screen and high enough to insert multiple line of text if needed.

Here is the image i will use (reduced to 700 pixels for this page):



Here are some sample buttons created with this technique, click on them to see the effect :



To achieve this effect you need two things :

First, you have to create your HTML content to display your buttons at the proper places formated the proper way, like this :

PHP Code:[Highlight]
<ul class="TheButton" style="font: 900 12px/16px 'Arial', Helvetica, sans-serif;">
 <
li><a href="#">
  <
span>Typical sliding doors button</span></a></li>
 <
li><a href="#">
  <
span><img src="/images/gcrown/on.gif" border="none" align="middle"
   
Typical sliding doors button with a lot more text in it...</span></a></li>
 <
li><a href="#">
  <
span>Typical sliding doors button with a lot more text in it
   
<br />and also having two lines of text in it...</span></a></li>
</
ul>
<
br style="clear:both;" /> 

Second, you need to create your CSS entries to view the buttons and links properly, here is how you do this :

PHP Code:[Highlight]
ul.TheButton {
        
padding0;
    
margin0;
    list-
stylenone;
    
floatleft;
}

ul.TheButton li {
    
floatleft;
    
displayinline/*For ignore double margin in IE6*/
    
margin0 10px;
}

ul.TheButton li a {
        
height74px;
    
text-decorationnone;
        
background-attachment:fixed;
    
backgroundurl(MyButton2.gifno-repeat top right;
    
padding-right22px;
    
float:left;
    
color#ff8;
    
cursorpointer;
}

ul.TheButton li a span {
        
height54px;
        /
height74px;
        
background-attachment:fixed;
    
backgroundurl(MyButton2.gifno-repeat top left;
    
margin0 0 0 -20px;
    
padding11px 8px 0px 18px;
    
positionrelative/*To fix IE6 problem (not displaying)*/
    
float:left;
}
ul.TheButton li a:hover {
    
color#8ff;
}
ul.TheButton li a:active {
    
color#7dd;
    
background-positionright 3;
}
ul.TheButton li a:active span{
    
color#7dd;
    
background-positionleft 3;
        
padding-top14px;


This is what was used to create the 3 first buttons in the precedent frame. You can use this method to create vertical and horizontal menus easily...

The buttons are created with two sections, the left one is the one containing the "link" and the right one is just a copy of the right end of the image.

The images movements are done using the link CSS attributes changing only the vertical placement of the background images and the vertical padding of the text.

Some old versions of Internet Explorer have difficulties achieving the images movement because they do not react to the mouse click properly. This can be corrected using javascript to do the job, using this :

PHP Code:[Highlight]
<script>
function 
buttonin(obj){
  if (
navigator.appName.indexOf('Netscape') == -1)
  {
    var 
MySpan obj.getElementsByTagName('span');
    
MySpan[0].style.color "#8ff";
  }
}
function 
buttondown(obj){
  if (
navigator.appName.indexOf('Netscape') == -1)
  {
    var 
MySpan obj.getElementsByTagName('span');
    
MySpan[0].style.color "#7dd";
    
MySpan[0].style.backgroundPosition "left 3";
    
MySpan[0].style.paddingTop "14px";
    
obj.style.backgroundPosition "right 3";
  }
}
function 
buttonup(obj){
  if (
navigator.appName.indexOf('Netscape') == -1)
  {
    var 
MySpan obj.getElementsByTagName('span');
    
MySpan[0].style.color "#8ff";
    
MySpan[0].style.backgroundPosition "left top";
    
MySpan[0].style.paddingTop "11px";
    
obj.style.backgroundPosition "right top";
  }
}
function 
buttonout(obj){
  if (
navigator.appName.indexOf('Netscape') == -1)
  {
    var 
MySpan obj.getElementsByTagName('span');
    
MySpan[0].style.color "#ff8";
  }
}
</script> 


To use the javascript you need to modify your HTML code for this instead :

PHP Code:[Highlight]
<ul class="TheButton" style="font: 900 12px/16px 'Arial', Helvetica, sans-serif;">
 <
li><a href="#"
  
onmouseover="buttonin(this);"
  
onmousedown="buttondown(this);"
  
onmouseup="buttonup(this);" 
  
onmouseout="buttonout(this);">
  <
span>Typical sliding doors button</span></a></li>
 <
li><a href="#"
  
onmouseover="buttonin(this);"
  
onmousedown="buttondown(this);"
  
onmouseup="buttonup(this);" 
  
onmouseout="buttonout(this);">
  <
span><img src="/images/gcrown/on.gif" border="none" align="middle"
   
Typical sliding doors button with a lot more text in it...</span></a></li>
 <
li><a href="#"
  
onmouseover="buttonin(this);"
  
onmousedown="buttondown(this);"
  
onmouseup="buttonup(this);" 
  
onmouseout="buttonout(this);">
  <
span>Typical sliding doors button with a lot more text in it
   
<br />and also having two lines of text in it...</span></a></li>
</
ul

This is all for the moment i will continue the explanations soon.

Meantime you can use this code freely
(without the images that are copyrighted to Regentronique) and look at these new sample buttons i just made using a 2 images technique :




exdiogene's signature MyBBCodes.com administrator
Cool " It is not what you know that matters, it is what you do or do not do!"
Visit this user's website Find all posts by this user
Quote this message in a reply
02-05-2010, 12:23 AM
Post: #2
RE: Sliding door buttons technique revisited...
eh? i dont really get it. where's the open door thingy

LuminousX's signature
Visit this user's website Find all posts by this user
Quote this message in a reply
03-19-2010, 01:58 AM
Post: #3
RE: Sliding door buttons technique revisited...
Very useful dude thx

Chandy's signature
Visit this user's website Find all posts by this user
Quote this message in a reply
06-05-2010, 08:34 AM
Post: #4
RE: Sliding door buttons technique revisited...
(02-05-2010 12:23 AM)LuminousX Wrote:  eh? i dont really get it. where's the open door thingy

The sliding door effect is attibuted to the fact that two images are kind-of overlapping themself for different width, like the movement of a sliding door...

Wink

exdiogene's signature MyBBCodes.com administrator
Cool " It is not what you know that matters, it is what you do or do not do!"
Visit this user's website Find all posts by this user
Quote this message in a reply
0 member(s) viewed this thread in the last 365 days :
Post Reply 


Was This Thread Useful ?
Please Link To Us
URL
BBCode
HTML

Forum Jump:

 
New To Site ?
Some Useful Links
  • Help

  • You Might Need To Register

  • Forum Statistics

  • Mark All Forums Read

  • Forum Staff

  • Log Out
  • Contact Us

  • Mybbcodes

  • Return to Top

  • Return to Content

  • Lite (Archive) Mode

  • RSS Syndication
  • Powered By MyBB, © 2002-2024 MyBB Group.
    Golden Crown - Designed and Published by ghazal & exdiogene of MyBBCodes.
    Hosting provided by WWWHostingServer.com