首页 > 其他 > 详细

属性选择器

时间:2017-02-16 11:32:14      阅读:146      评论:0      收藏:0      [点我收藏+]

1、[attribute]

a[target]
{
background-color:yellow;
}

<a href="#">aaa</a>

<a href="#" target="_blank">bbb</a>

2、[attribute=value]

a[target=_blank]
{
background-color:yellow;
}

<a href="#">aaa</a>

<a href="#" target="_blank">bbb</a>

3、[attribute~=value]:对属性中包含flower的元素进行样式设置

[title~=flower]
{
border:5px solid yellow;
}

<img src="/i/eg_tulip.jpg" title="tulip flower" />

4、[attribute|=value]:对于属性中以en开头的元素进行样式设置

[lang|=en]

{
background:yellow;
}

<p lang="en-us">Hi!</p>

5、[attribute^=value]:css3的属性,设置 class 属性值以 "test" 开头的所有 div 元素的背景色:

div[class^="test"]
{
background:#ffff00;
}

<div class="test"> div 元素。</div>

6、[attribute$=value]css3的属性,设置 class 属性值以 "test" 结尾的所有 div 元素的背景色:

div[class$="test"]
{
background:#ffff00;
}

<div class="first_test">第一个 div 元素。</div>

7、[attribute*=value]:设置 class 属性值包含 "test" 的所有 div 元素的背景色

div[class*="test"]
{
background:#ffff00;
}

<div class="first_test">第一个 div 元素。</div>

属性选择器

原文:http://www.cnblogs.com/lyne11/p/6404406.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!