On the application of CSS combination and CSS nesting
Source: Internet
Author: User
For example, you have the following code:
h2 {color:red;}
. abc {color:red;}
. abccom {color:red}
Then you can write this:
h2,.abc,.abccom {color:red;}
Using a combination, you can define multiple CSS at a time, saving you a lot of bytes and time.
CSS Nesting
CSS structure is good, there is no need to use too many classes or identity selectors. This is because you can specify the selector within the selector character. (or better yet, contextual selectors--the translator)
Like what:
#top {background-color: #ccc; padding:1em}
#top H1 {color: #ff0;}
#top p {color:red; font-weight:bold;}
This subtracts unnecessary classes or identity selectors, if applied to HTML like this:
<div id= "Top" >
<p>this is I recipe for making curry purely with chocolate</p>
<p>mmm mm mmmmm</p>
</div>
This is because, with the English half-width space interval selector, we have indicated that the H1 in the identification ID has a "#ff0" color, while P is red and bold.
This may also be somewhat complicated (because there may be more than two levels, such as within the inner inner and so on). You need to practise more.
With nesting, you can make your CSS code read clearer and customize CSS for the elements you make.
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.