Selectors

2018-05-15 17:26 更新
先決條件: 基本的計算機素養(yǎng), 安裝必備的軟件 basic software installed, basic knowledge of working with files, HTML basics (study Introduction to HTML), and an idea of How CSS works.
目的: 要了解CSS選擇器如何工作的細節(jié).

基礎(chǔ)

在上一篇文章中,我們詳細介紹了 CSS語法和術(shù)語 回顧一下,選擇器是CSS規(guī)則的一部分,并且恰好在CSS聲明塊之前。

不同種類的CSS選擇器:

選擇器可以分為以下類別:

  • Simple selectors (簡單選擇器): Match one or more elements based on element type, class, or id.
  • Attribute selectors (屬性選擇器): Match one or more elements based on their attributes/attribute values.
  • Pseudo-classes?(偽類選擇器): Match one or more elements that exist in a certain state, such as an element that is being hovered over by the mouse pointer, or a checkbox that is currently disabled or checked, or an element that is the first child of its parent in the DOM tree.
  • Pseudo-elements?(偽元素選擇器): Match one or more parts of content that are in a certain position in relation to an element, for example the first word of each paragraph, or generated content appearing just before an element.
  • Combinators (組合選擇器): These are not exactly selectors themselves, but ways of combining two or more selectors in useful ways for very specific selections. So for example, you could select only paragraphs that are direct descendants of divs, or paragraphs that come directly after headings.
  • Multiple selectors (多樣 選擇器): Again, these are not separate selectors; the idea is that you can put multiple selectors on the same CSS rule, separated by commas, to apply a single set of declarations to all the elements selected by those selectors.

選擇器文章概述

接下來的四篇文章都探討了選擇器的不同方面 - 我們已經(jīng)打破了這些信息,因為它有很多,我們希望使它不那么嚇人,并給你一些明確的要點,在中學期間休息。 文章如下:

強烈建議您先處理簡單選擇器,以防您錯過任何相關(guān)信息。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號