css syntax, and css selectors

CSS syntax

CSS standard syntax is mainly composed of First selector consists of two aspects. Second, the statement box.

First, the selector      can select page elements specified by the selector and the style declaration block applications selected by the selector element to go.

Second, the block statement      is a sign, a statement immediately after the selector block, which is actually the block declaration attribute names and attribute values corresponding in structure to the set {a} of a group. Call statement, a block statement can have multiple claims. Between a plurality of statements using a semicolon; be separated, with values between declaration The styles: connection.

Common CSS selectors

Element selectors   to select all of the specified page element (selector element is the name) by the element selector

The I D is selected       by the ID attribute value of the element, to select only one element.

Class selector      by setting the class attribute for the element, class attribute ID and the like properties, but may be repeated class attribute, the attribute class have the same set of elements is called an element. Plurality may be provided as a class attribute value element may be used between a plurality of values separated by a space.

And set the selector   to select grouping, can select a plurality of elements corresponding to the same time selectors (selector 1 and selector 2, the selector {3}) shows the effect of: satisfying the selector 1 and selector 2 satisfies satisfy the selection 3 the elements are selected simultaneously, are selected among the plurality of sets and relationships.

The selector Wild   Wild selector may select all the elements in the page (* {}) .

Composite selector (selector intersection) can select a plurality of simultaneously satisfying a plurality of selector elements (1 Selector Selector Selector 3 {2}) for the ID selector is not advised intersection selector.

后代选择器   选中制定元素的指定后代元素(祖先元素 后代元素{  })也可以写后代的后代的后代元素。但是尽量不要写的太长,考虑到性能问题选择器尽量写的短一些。

子元素选择器   比如说span元素是p元素的子元素,就可以写成  p>span{   }

伪类选择器    伪类是专门用来表示元素的一种特殊状态,比如说常见的 a 元素的一些特殊状态(原始状态的超链接,访问过的超链接,运行中的超链接等等),当我们需要为这些处在特殊状态的元素设置样式的时候就可以使用伪类来定义。详细内容会在下篇具体介绍。

Guess you like

Origin www.cnblogs.com/nyw1983/p/11261616.html