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

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

直接上代码:

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

效果如下:

相关推荐
说私域11 小时前
技术赋能直播运营:开源AI智能名片商城小程序助力个人IP构建与高效运营
人工智能·tcp/ip·小程序·流量运营·私域运营
说私域12 小时前
流量思维向长效思维转型:开源链动2+1模式AI智能名片小程序赋能私域电商品牌建设
人工智能·小程序·开源·产品运营·私域运营
说私域1 天前
链动2+1模式AI智能名片S2B2C商城小程序在微商信任重建中的创新应用与价值实现
大数据·人工智能·小程序·私域运营
qq_24218863321 天前
微信小程序AI象棋游戏开发指南
人工智能·微信小程序·小程序
予你@。2 天前
UniApp + Vue3 实现 Tab 点击滚动定位(微信小程序)
微信小程序·小程序·uni-app
大黄说说2 天前
小程序商城哪个平台好?码云数智、有赞、微盟对比
小程序
游戏开发爱好者82 天前
完整教程:App上架苹果App Store全流程指南
android·ios·小程序·https·uni-app·iphone·webview
潆润千川科技2 天前
中老年同城社交小程序功能梳理与应用分析
小程序
说私域2 天前
数字化运营视角下用户留存体系构建与实践研究——以AI智能客服商城小程序为载体
人工智能·小程序·产品运营·流量运营·私域运营
码云数智-大飞2 天前
小程序商城哪个平台好?小程序商城制作平台深度对比
微信小程序