码迷,mamicode.com
首页 > Web开发 > 详细

css 记录

时间:2018-06-19 11:52:55      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:code   com   lan   一个   css   weight   head   tar   pre   

例子 1 - 匹配第一个 <p> 元素

在下面的例子中,选择器匹配作为任何元素的第一个子元素的 p 元素:

<html>
<head>
<style type="text/css">
p:first-child {
  color: red;
  } 
</style>
</head>

<body>
<p>some text</p>
<p>some text</p>
</body>
</html>

 

例子 2 - 匹配所有 <p> 元素中的第一个 <i> 元素

在下面的例子中,选择器匹配所有 <p> 元素中的第一个 <i> 元素:

<html>
<head>
<style type="text/css">
p > i:first-child {
  font-weight:bold;
  } 
</style>
</head>

<body>
<p>some <i>text</i>. some <i>text</i>.</p>
<p>some <i>text</i>. some <i>text</i>.</p>
</body>
</html>

 

例子 3 - 匹配所有作为第一个子元素的 <p> 元素中的所有 <i> 元素

在下面的例子中,选择器匹配所有作为元素的第一个子元素的 <p> 元素中的所有 <i> 元素:

<html>
<head>
<style type="text/css">
p:first-child i {
  color:blue;
  } 
</style>
</head>

<body>
<p>some <i>text</i>. some <i>text</i>.</p>
<p>some <i>text</i>. some <i>text</i>.</p>
</body>
</html>

TIY

css 记录

标签:code   com   lan   一个   css   weight   head   tar   pre   

原文地址:https://www.cnblogs.com/my2018/p/9197514.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!