Get the App
SLTechnology News&Howtos  ›  Development  › 

Case Analysis of CSS derived Selector

Shulou Source: shulou.com Published: 2022-06-01 04:09:52 09月22日 Update

Most people do not understand the knowledge points of this "CSS derivative selector case analysis" article, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "CSS derivative selector case analysis" article.

In modern layouts, id selectors are often used to build derived selectors.

# sidebar p {

Font-style: italic

Text-align: right

Margin-top: 0.5em

}

The above style applies only to paragraphs that appear within elements where id is sidebar. This element is most likely a div or a table cell, although it may also be a table or other block-level element. It can even be an inline element, such as or, but this usage is illegal because it cannot be embedded in an inline element

(if you forget why, see XHTML: site refactoring).

One selector, multiple uses

This id selector can be used many times as a derived selector, even if the element marked as sidebar can appear only once in the document:

# sidebar p {

Font-style: italic

Text-align: right

Margin-top: 0.5em

}

# sidebar h3 {

Font-size: 1em

Font-weight: normal

Font-style: italic

Margin: 0

Line-height: 1.5

Text-align: right

}

Here, the p element in sidebar is treated differently from the other p elements on the page, and the h3 element in sidebar is also treated differently from all other h3 elements in the page.

The above is about the "CSS derived selector case analysis" of this article, I believe we all have a certain understanding, I hope the editor to share the content to help you, if you want to know more related knowledge, please follow the industry information channel.

Tags: Element selection content example case analysis analysis different obvious special article knowledge article table page processing value unit reason at the same time multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Shulou Technology Redmi MariaDB