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

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

直接上代码:

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

效果如下:

相关推荐
大米饭消灭者3 天前
Taro是怎么实现一码多端的【底层原理】
微信小程序·taro
FliPPeDround4 天前
Vitest Environment UniApp:让 uni-app E2E 测试变得前所未有的简单
微信小程序·e2e·前端工程化
FliPPeDround4 天前
微信小程序自动化的 AI 新时代:wechat-devtools-mcp 智能方案
微信小程序·ai编程·mcp
吴声子夜歌4 天前
小程序——布局示例
小程序
码云数智-大飞4 天前
如何创建自己的小程序,码云数智与有赞平台对比
微信小程序
luffy54594 天前
微信小程序页面使用类似filter函数的wxs语法
微信小程序·小程序
Slow菜鸟4 天前
微信小程序开发(二)目录结构完全指南
微信小程序·小程序
攀登的牵牛花4 天前
给女朋友写了个轻断食小程序:去老丈人家也是先动筷了
前端·微信小程序
前端小雪的博客.4 天前
【保姆级教程】uniAI 插件高效开发 uni-app 微信小程序(附实战案例)
微信小程序·uni-app·ai编程·uniai
小小王app小程序开发4 天前
海外盲盒小程序抽赏玩法分析(附跨境技术落地要点)
小程序