1

there are two class that start with post-meta- like this.

<div class="post-meta-top"></div>
<div class="main-text"></div>
<div class="post-meta-bottom"></div>

Normally I must write like .post-meta-top, .post-meta-bottom, but if possible I want to write like .post-meta-*.

I know it's impossible with scss right now. My question is "Is there similar function in scss or in other css extended language?"

4

2 回答 2

2

您可以使用属性选择器执行此操作

div[class^='post-meta-']
{
  ..
}

小提琴

w3c 规范

[att^=val]

表示具有 att 属性的元素,其值以前缀“val”开头。如果 "val" 是空字符串,则选择器不代表任何内容。

于 2013-10-10T10:09:38.733 回答
-1

你可以尝试jQuery匹配多个类,

<script>
    $( "div[class^='post-meta']" )
</script>
于 2013-10-10T10:08:45.070 回答