我有这个:
<div class="likebutton" numberlikes$post="$totallikes">
$post是PHP发送的id号。
我的问题是CSS如何理解我想要的numberlike后面有任何数字,例如:numberlikes63463436numberlikes548548…
我的css:
.likebutton:before{
color: #FFFFFF;
content: attr(numberlikes);
background:blue;
padding: 0 10px;
margin-right: 5px;
display: inline-block;
}
我如何告诉css numberlikes后面会有一个随机数?我试着在numberlikes后面放=^id,但它不起作用…
content: attr(numberlikes=^id);
谢谢!
不要把$post
放在属性名中,把它放在id
属性中。
.likebutton:before{
color: #FFFFFF;
content: attr(data-numberlikes);
background:blue;
padding: 0 10px;
margin-right: 5px;
display: inline-block;
}
<div class="likebutton" id="likebutton$post" data-numberlikes="$totallikes">