微信小程序上,实现图片右上角数字显示
直接上代码:
样式代码index.wxss如下:
.circle_rednum {position: absolute;color: white;font-size: 13px;background-color: #EC2F43;width: 23px;height: 23px;line-height: 23px;left: 80%;top: -2px;text-align: center;-webkit-border-radius: 24px;border-radius: 24px;
}
前端代码index.wxml如下:
<view class="item_parent" ><view class="img-bg"><image class="menu_img" src="../../images/home/module1.png" mode="cover"></image><p class="circle_rednum" wx:if="{{floatNewNum>0&&floatNewNum<=99}}">{{floatNewNum}}</p><p class="circle_rednum" wx:if="{{floatNewNum>99}}">99+</p></view><text class="menu_text">新工单</text></view>
微信小程序的效果为:
再分享一个html版本的css右上角显示带数字的圆圈的代码
<html><head><meta charset="UTF-8"><title></title><style>.alarm {position: relative;width: 60px;height: 60px;margin: 60px;}.alarm img {width: 60px;height: 60px;}.divright {position: absolute;color: white;font-size: 17px;background-color: red;width: 23px;height: 23px;line-height: 23px;left: 80%;top: -12px;text-align: center;-webkit-border-radius: 24px;border-radius: 24px;}</style></head><body><div class="alarm"><img src="https://img.zcool.cn/community/01c4e855ed3cc46ac7251df84fcbfb.gif" /><div class="divright">3</div></div></body>
</html>
效果如下: