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

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

直接上代码:

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

效果如下:

相关推荐
说私域17 分钟前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的零售流量重构研究
人工智能·小程序·开源
鹧鸪云光伏与储能软件开发2 小时前
光伏开发小程序:快速获客,成交项目更迅速
大数据·微信小程序·小程序·光伏
晨旭缘4 小时前
解决小程序滚动穿透问题
小程序
游戏开发爱好者87 小时前
iOS 崩溃日志分析工具全指南,多工具协同构建稳定性分析体系
android·macos·ios·小程序·uni-app·cocoa·iphone
00后程序员张17 小时前
如何提高 IPA 安全性 多工具组合打造可复用的 iOS 加固与反编译防护体系(IPA 安全 iOS 加固 无源码混淆 Ipa Guard 实战)
android·安全·ios·小程序·uni-app·iphone·webview
游戏开发爱好者818 小时前
Fiddler抓包实战教程 从安装配置到代理设置,详解Fiddler使用方法与调试技巧(HTTPHTTPS全面指南)
前端·测试工具·小程序·https·fiddler·uni-app·webview
sen_shan19 小时前
《微信小程序》第五章:登录-API封装
微信小程序·小程序
2501_916007471 天前
Fastlane 结合 开心上架 命令行版本实现跨平台上传发布 iOS App
android·ios·小程序·https·uni-app·iphone·webview
00后程序员张1 天前
iOS 26 内存占用监控 多工具协同下的性能稳定性分析实战
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_915909061 天前
iOS 26 性能监控工具有哪些?多工具协同打造全方位性能分析体系
android·macos·ios·小程序·uni-app·cocoa·iphone