Using First-child in IE

Source: Internet
Author: User

So is it better to distinguish between the first and the last? The answer is obvious, force, do not use the difference between the last one. According to the general programming method, it is much easier to control the first item than to control the last one.

Another benefit of distinguishing the first is that CSS has one: first-child artifacts (pseudo element) allow us to easily select the first child element.

Unfortunately, the current world's most-occupied browser, IE6, does not support this pseudo element. We can manually add class to the first element and then define it. But this is not a foolproof method, especially for the size of the page to reach a certain number of large sites, it is easy to exhaustive. So, how about having JavaScript help us finish this job?

View Demo

In IE, for each first-child Li plus First-child class, then the CSS can be written:: First-child,. first-child {Some rules here ...} (Did you find this very handsome, a colon, two points, a dot, a point), very easy to maintain and manage.

P.S. I hope that a master can write generic first-child, I here the example only for Li, limited capacity!



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.