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

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

直接上代码:

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

效果如下:

相关推荐
吴声子夜歌4 小时前
小程序——项目结构
小程序
大黄说说4 小时前
微信小程序制作平台有哪些?SaaS小程序搭建平台推荐
微信小程序
Lucky小黄人1 天前
微信小程序查看备案号
微信小程序·小程序
码云数智-园园1 天前
小程序制作平台哪个好?微信小程序制作平台对比评测
微信小程序
毕设源码-郭学长1 天前
【开题答辩全过程】以 基于微信小程序的当当手办店铺为例,包含答辩的问题和答案
微信小程序·小程序
qq_24218863321 天前
微信小程序新年首页源码
微信小程序·小程序
中国胖子风清扬2 天前
GPUI 在 macOS 上编译问题排查指南
spring boot·后端·macos·小程序·rust·uni-app·web app
玛雅牛牛3 天前
多款物流信息哪款更适合
小程序
说私域3 天前
技术赋能直播运营:开源AI智能名片商城小程序助力个人IP构建与高效运营
人工智能·tcp/ip·小程序·流量运营·私域运营
说私域3 天前
流量思维向长效思维转型:开源链动2+1模式AI智能名片小程序赋能私域电商品牌建设
人工智能·小程序·开源·产品运营·私域运营