How to create interesting buttons with css (latest translation)

Source: Internet
Author: User

Sliding Door

To make the buttons flexible, we must make the background image automatically adapt to the text width of the buttons. To this end, we need to use the sliding door technology, combine two background images into one background image. The button uses the tag and span tag. They use different parts of the background image, and the html code is as follows:

<A class = "button" href = "#"> <span> search </span> </a>

Nothing extraordinary happens, right? We need to design simple and clear buttons. The following is my idea:

 

Each graph contains two statuses of the button: normal and pressed. We arrange the two statuses of images in an alternating vertical manner. This css technique can be used without any javascript script to complete the changes. Next we will use the sliding door technology to make the button adaptive to the width of the text, we make the image wider, such as 300px and 24px:

Span

 

Button style

Finally, we will use css to integrate all of this:

A. button {
Background: transparent url (''images/bg_button_a.gif '') no-repeat scroll top right;
Color: #444;
Display: block;
Float: left;
Font: normal 12px arial, sans-serif;
Height: 24px;
Margin-right: 6px;
Padding-right: 18px;
Text-decoration: none;
}

A. button span {
Background: transparent url (''images/bg_button_span.gif '') no-repeat;
Display: block;
Line-height: 14px;
Padding: 5px 0 5px 18px;
}

 

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.