好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CSS:基本语法及派生选择器_html/css_WEB-ITnose

本文介绍css基本语法及派生选择器。

代码整理自w3school:http://www.w3school.com.cn

(一)基础部分:

      h1,h2,h3 {color:red;background-color:#ccc}li strong {font-style:italic;}   CSS基础    

h1,h2,h3 级标题为CSS样式指定为灰底红字

h1,h2,h3 级标题为CSS样式指定为灰底红字

h1,h2,h3 级标题为CSS样式指定为灰底红字

h4级标题没有被指定样式

派生选择器允许你根据文档的上下文关系来确定某个标签的样式。

我是粗体字,不是斜体字,因为我不在列表当中,所以这个规则对我不起作用

我是斜体字。这是因为 strong 元素位于 li 元素内。 我是正常的字体。

效果图:

(二)样式的“覆盖”规则

            strong {color: red;}    h2 {color: red;}    h2 strong {color: blue;}     CSS基础-样式的“覆盖”规则    

The strongly emphasized word in this paragraph is red .

This subhead is also red.

The strongly emphasized word in this subhead is blue .


效果图:

查看更多关于CSS:基本语法及派生选择器_html/css_WEB-ITnose的详细内容...

  阅读:31次