微信小程序上,实现图片右上角数字显示

微信小程序上,实现图片右上角数字显示

直接上代码:

样式代码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>

效果如下:

相关推荐
HERR_QQ1 天前
【unify】unify的微信小程序开发学习 (to be continued)
学习·微信小程序·小程序
racerun1 天前
小程序导航设置更多内容的实现方法
小程序
说私域1 天前
基于开源AI智能名片链动2+1模式S2B2C商城小程序的超级文化符号构建路径研究
人工智能·小程序·开源
mg6681 天前
微信小程序入门实例_____快速搭建一个快递查询小程序
微信小程序·小程序
程序员柳1 天前
基于微信小程序的校园二手交易平台、微信小程序校园二手商城源代码+数据库+使用说明,layui+微信小程序+Spring Boot
数据库·微信小程序·layui
Jyywww1212 天前
微信小程序学习笔记
笔记·学习·微信小程序
The_era_achievs_hero2 天前
微信小程序41~50
微信小程序·小程序
走,带你去玩2 天前
uniapp 微信小程序水印
微信小程序·小程序·uni-app
是一碗螺丝粉2 天前
🔥 微信H5视频自动播放终极秘籍:WeixinJSBridge竟是官方“通行证”?
微信小程序