attr作为css选择器中的属性 [英] attr as property in css selector

查看:124
本文介绍了attr作为css选择器中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

CSS选择器按样式属性


html:

 < div data-family ='arial'>< / div> 

在css我想使用这个家庭值。示例:

  div {font-family:attr(data-family)} 

家庭可以是任何字符串。

  div [data-weight =bold] {
font-weight:bold;
}

http://www.w3.org/TR/selectors/#attribute-selectors



JSFIDDLE


Possible Duplicate:
CSS selector by style attribute

html:

<div data-family='arial'></div>

in css i want to use this family value. Example:

div{font-family: attr(data-family)}

Family can be any string. How make it work?

解决方案

Try this code:

 div[data-weight="bold"]{
      font-weight: bold;
    }

http://www.w3.org/TR/selectors/#attribute-selectors

JSFIDDLE

这篇关于attr作为css选择器中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆