Webpage instance: use CSS to create a webpage button with a style

Source: Internet
Author: User

Today, I redesigned the buttons made by the previous designer on the company's platform. Originally, he used JavaScript to achieve alternate image changes. However, the disadvantages are: it occupies the ID attribute in input, and disabled cannot be used, which is not conducive to program design and production.
The idea of button re-creation:
1. Differences between trigger and non-trigger;
2. Applicable to input and;
3. There is no difference between different browsers.
Button re-creation process:
1. Use different styles to achieve the difference between triggering and not triggering;
2. Use boder to simulate button shadow
The following code is normal in IE6, IE7, and FF!
CSS section:

The code is as follows: Copy code
. Button-style01 {
Color: #5E7384;
Font-weight: bold;
Background: # CBDBE5;
Border-top: 1px solid # f1f1f1;
Border-left: 1px solid # f1f1f1;
Border-right: 2px solid #666;
Border-bottom: 2px solid #666;
Height: 25px
}
. Button-style02 {
Color: # fff;
Font-weight: bold;
Background: # 859BAB;
Border: 1px solid # f1f1f1;
Border-top: 1px solid # f1f1f1;
Border-left: 1px solid # f1f1f1;
Border-right: 2px solid #666;
Border-bottom: 2px solid #666;
Height: 25px
}
A. Button-style01, a. Button-style02 {
Display: block;
Height: 22px;
Line-height: 22px;
Vertical-align: middle;
Padding: 0px 8px;
}
A. Button-style01: link, a. Button-style01: visited {
Text-decoration: none;
Color: #5E7384;
Border-top: 1px solid # f1f1f1;
Border-left: 1px solid # f1f1f1;
Border-right: 2px solid #666;
Border-bottom: 2px solid #666;
}
 
A. Button-style02: hover, a. Button-style02: active {
Text-decoration: none;
Color: # fff;
Border-top: 1px solid # f1f1f1;
Border-left: 1px solid # f1f1f1;
Border-right: 2px solid #333;
Border-bottom: 2px solid #333;
}
Xhtml section:
<Input type = "submit" name = "login" id = "login" onclick = "myoffice. submit () "value =" Sign in "onmouseover =" this. className = 'Button-style02' "onmouseout =" this. className = 'Button-style01' "class =" button-style01 "style =" width: 70px; "/>
<A href = "#" onmouseover = "this. className = 'Button-style02' "onmouseout =" this. className = 'Button-style01' "class =" button-style01 "> Join Free </a>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.