Graphical tutorial on designing buttons using sliding door technology_Experience exchange

PHP中文网
Release: 2016-05-16 12:07:39
Original
1915 people have browsed it

this article is a translated article, full text address: http://diger.cn/article.asp? id=351
original address: http://www.filamentgroup.com/ lab/buttonelement/

particle tree recently published an article describing a technique they came up with for designing button elements. for those unskilled, table buttons are notoriously difficult to customize. typical solutions are to use the default buttons provided by the browser, or to use a graphical input. when the graphics input completes the desired result, it requests the creation of a new graphics for each button with its text "baked-in" (no mention of swapping it with hovers).

although particle tree's technology provides a reliable solution, it cannot meet our needs. we need a button that uses sliding door technology, a real html text that doesn't require javascript to scroll or submit a form. meeting these conditions means that input and anchor elements are excluded. obviously, the button element is our only choice. the following technique demonstrates a cross-browser button technique using sliding door technology.


view demo

tag:

the code is as follows:

<button value="submit" class="submitbtn"><span>submit</span></button>
Copy after login

css:

the program code is as follows:

button {   
  border:0;   
  cursor:pointer;   
  font-weight:bold;   
  padding:0 20px 0 0;   
  text-align:center;   
}  
button span {   
  position:relative;   
  display:block;   
  white-space:nowrap;   
  padding:0 0 0 20px;   
}  
/*blue buttons*/  
button.submitbtn {   
  background:url(images/btn_blue_right.gif) right no-repeat;   
  font-size:1.3em;   
}  
button.submitbtn span {   
  height:50px;   
  line-height:50px;  
  background:url(images/btn_blue_left.gif) left no-repeat;  
  color:#fff;   
}  
button.submitbtn:hover {  
    background:url(images/btn_blue_right_hover.gif) right no-repeat;   
}  
button.submitbtn:hover span {  
    background:url(images/btn_blue_left_hover.gif) left no-repeat;   
}
Copy after login


css for ie6 and ie7 (sometimes required)
the code is as follows:

button {   
  width:auto;   
  overflow:visible;   
}  
button span {   
  margin-top:1px;   
}
Copy after login

as you can see, each state uses 2 images (4 images total). simplifying further, these states can be transformed into two. but initial tests of the idea turned up inconsistent results.











browser support:
ie6, ie7, firefox (mac/pc), safari, opera, camino, etc.

warning: in order for hover to work in ie6, you will need to write a class trigger. not as bad as picture swapping though.

the above is the graphic tutorial on designing buttons using sliding door technology_the content of experience exchange. for more related content, please pay attention to the php chinese website (www.php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template