传递:带有html属性的content属性之后

时间:2014-07-08 19:50:23

标签: html css html5

我有一些div,每个:after元素都需要不同的内容属性。 我不可能单独设置每个div的样式,因为div的数量相当大。

我的问题:我可以在html标签中传递属性吗? 说我有

<a href="#" class="vak">Engels</a>

使用:after样式

content: "this needs to change";
display: inline-block;
color: #A9B0BB;  
float: right;
font-style:italic;

如何在html中传递this needs to change字符串?有一个更好的方法吗? (最好不使用js)

1 个答案:

答案 0 :(得分:5)

您可以使用它的属性:

<a title="this will be displayed in the :after">test</a>

CSS:

a:after {
    content: attr(title);
    display: inline-block;
    color: #A9B0BB;  
    float: right;
    font-style: italic;
}

Fiddle

相关问题