CSS Web design experience sharing: negative margin

Source: Internet
Author: User

Article Introduction: negative margin is a good thing.

The project completed last month, let me have a tangled n-hour module, first figure:

The default state is gray, without a circle, the completed state is red, the current display is yellow, and the circle is in the middle of two words, the last status is "successful" if it is gray, the line is less than the text, but the rest is consistent. The prototype code is as follows, for the JS structure of course the simpler the better:

<ul>
< li class= "status_finished" > Selection </li>
< li class= "status_current" > Reservation </li>
< li> payment </li>
< li> success </li>
</ul>

It's time to get tangled: the color of the circles around the circle is different, if cut together the last state to be applied alone without the right superfluous lines of the picture, is equal to cut two sets of drawings, the scheme to give up; if each state is only cut to the circle part, leave a blank on the right, it will appear in the middle of two words, But how does the next state continue to the left? There is a way: negative margin~ ~ ~

Enlarged Effect Chart:

The style is as follows:

UL {margin:36px auto; height:30px;}
UL li {float:left; width:164px; margin-right: -6px; padding-top:15px; text-align:right; Background:url ("Xxxx.gif") n O-repeat right xxpx; Color: #666; }
UL li.status_finished {background-position:right xxpx;}
UL li.status_current {background-position:right xxpx; font-weight:bold; color: #000;}

Note: When merging pictures, the right side of the circle should be set aside for 6px (the specific value is determined according to the actual situation) transparent void, the left line for adaptive consideration as long as possible.



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.