CSS 實(shí)現(xiàn)頭像圖片右上角數(shù)字顯示

使用 CSS 實(shí)現(xiàn)頭像圖片右上角數(shù)字顯示,常見于微信、QQ等聊天工具。
實(shí)現(xiàn)思路

  • 兩個(gè)盒子
  • 子絕父相定位
  • 一些樣式問題


    學(xué)賢社
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS 實(shí)現(xiàn)圖片右上角數(shù)字顯示</title>
    <style>
        .box {
            height: 60px;
            width: 60px;
            position: relative;
            margin: 100px auto;
        }
        .box img {
            width: 100%;
            height: 100%;
        }
        .box .number {
            position: absolute;
            left: 80%;
            top: -12px;
            background-color: red;
            color: #fff;
            line-height: 23px;
            width: 23px;
            border-radius: 24px;
            text-align: center;
            font-size: 17px;
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="https://upload.jianshu.io/users/upload_avatars/16069544/8e5ccee8-9c9e-4345-bbaa-8f32ec595557.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/240/h/240" alt="">
        <span class = "number">2</span>
    </div>
</body>
</html>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容