CSS after generation selector and multi-class selector

Source: Internet
Author: User

< new report, welcome to shoot Brick #-

One, descendant selector

Talk about the descendant selectors of CSS. It belongs to one of the derived selectors, and the subordinate relationships are as follows:

--Derivation Selector

----CSS descendant Selectors

----CSS child element selectors

----CSS adjacent Sibling selector

So the question is, when do I need to use the descendant selector? Suppose you need a SPAN element in the P element (. Class A) sets a special style that can be selected with the descendant selector:

/* Mode 1*/
P span{...}
/* Mode 2*/
P. A{...}

Note that the above code has two selectors separated by a space space space. In addition, descendant selectors are often free to use gray. Let's just say that the P element in the above example does not have to be a span father, as long as the immediate elders of span such as Grandpa can. In other words, the descendant selector works when the P element contains a SPAN element.

Second, multi-class selector

Next, say a multi-class selector. As an example:

. Funny {...} . Handsome {...} . Funny.handsome {...}

Note that there is no space separation between the two selectors for the above code. OK, now there are. Funny and. Handsome these two classes, obviously "I am a funny and handsome boy, both lack of one is not me" is a true proposition, so only ". Funny.handsome" This multi-class selector can choose me. But the individual ". Funny" Cannot choose me, for the same reason as the true proposition mentioned earlier, the ". Handsome" selector is identical.

All right, there's a lot of use for multi-class selectors, like setting "1, being clicked (. selected); 2, button style", you can use:

button.selected {...}

This is the first post I wrote in the blog Park, XD. Complete.

CSS after generation selector and multi-class selector

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.