我在Twitter 中有看到如下selector:
.show-grid [class*="span"] {
background-color: #eee;
text-align: center;
border-radius: 3px;
min-height: 30px;
line-height: 30px;
} 有哪位童鞋知道这种写法.
答: 这是一个属性通配符selector. 在你提供的例子中, 会在引用了.show-grid 样式的容器内查找包含span样式的任何元素并设置对应的样式 下面这个例子中, 将会找到 <strong> 组件. <div class="show-grid">
<strong class="span6">Blah blah</strong>
</div>
你也可以定义'以... 开始'的样式, 例如: div[class^="something"] { }
将会查找到如下的组件:- <div class="something-else-class"></div>
亦可以定义 '以...结尾' div[class$="something"] { }
将会查找到如下组件 <div class="you-are-something"></div>
|