dougehe2022 2015-08-03 11:16
浏览 54

带有id后面的CSS类名吗?

I have this:

<div class="likebutton" numberlikes$post="$totallikes">

$post is an id number that php sends.

my problem here is how can CSS understant that I want numberlikes with any number after it, eg: numberlikes63463436 numberlikes548548 ...

my css:

.likebutton:before{
 color: #FFFFFF;
 content: attr(numberlikes);
 background:blue;
 padding: 0 10px;
 margin-right: 5px;
 display: inline-block;
}

how can I tell css that numberlikes will have a random number after it? I try put =^id after numberlikes but it is not working...

content: attr(numberlikes=^id);

thank you!

  • 写回答

1条回答 默认 最新

  • dongshi9407 2015-08-03 11:27
    关注

    Don't put $post in the attribute name, put it in the id attribute.

    .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">

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式