角标

image.png

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. <style>
  9. html,
  10. body {
  11. width: 100%;
  12. height: 100%;
  13. display: flex;
  14. }
  15. div {
  16. position: relative;
  17. width: 200px;
  18. height: 64px;
  19. line-height: 64px;
  20. text-align: center;
  21. margin: auto;
  22. font-size: 24px;
  23. background: #03a9f4;
  24. color: #fff;
  25. border-radius: 32px;
  26. }
  27. div::before {
  28. content: attr(count);
  29. position: absolute;
  30. right: 10px;
  31. top: -8px;
  32. border-radius: 12px;
  33. padding: 0 8px;
  34. background: deeppink;
  35. font: 16px/1.5 sans-serif;
  36. transform: translate(50%, 0);
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <div>
  42. <div count="角标提示">Message</div>
  43. </div>
  44. </body>
  45. </html>

图片标识

image.png

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    body {
        padding: 20px;
    }

    .g-wrap {
        position: absolute;
        cursor: pointer;
    }

    img {
        position: relative;
        width: 300px;
    }

    [desc1]::before,
    [desc2]::after {
        position: absolute;
        padding: 4px 10px 4px 20px;
        font-size: 12px;
        color: #333;
        z-index: 10;
        opacity: 0;
        transition: all .5s;
    }

    [desc1]::before {
        content: attr(desc1);
        right: 2%;
        top: 10%;
        background:
            radial-gradient(10px at 12% 50%, #333 0%, #333 2.5px, transparent 2.5px),
            linear-gradient(135deg, transparent 7px, #fff 7px, #fff 100%) top left,
            linear-gradient(45deg, transparent 7px, #fff 7px, #fff 100%) bottom left;
        background-size: 100% 100%, 100% 50%, 100% 50%;
        background-position: 0 0, 0 0, 0 100%;
        background-repeat: no-repeat;
        transform: translate(30px, 0);
    }

    [desc2]::after {
        content: attr(desc2);
        left: 8%;
        bottom: 20%;
        padding: 4px 20px 4px 10px;
        background:
            radial-gradient(10px at 88% 50%, #333 0%, #333 2.5px, transparent 2.5px),
            linear-gradient(-135deg, transparent 7px, #fff 7px, #fff 100%) top left,
            linear-gradient(-45deg, transparent 7px, #fff 7px, #fff 100%) bottom left;
        background-size: 100% 100%, 100% 50%, 100% 50%;
        background-position: 0 0, 0 0, 0 100%;
        background-repeat: no-repeat;
        transition-delay: .2s;
        transform: translate(-30px, 0);
    }

    [desc1]:hover::before,
    [desc2]:hover::after {
        opacity: 1;
        transform: translate(0px, 0);
    }
</style>

<body>
    <div class="g-wrap" desc1="商品描述AAA" desc2="商品描述BBB">
        <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1560086901480&di=3633d2d532f21a13d43e30aaf5db2a66&imgtype=0&src=http%3A%2F%2Fimg.94477.com%2F3206%2F1684912%2F5.jpg"
            alt="">
    </div>
</body>

</html>

html向css传值
image.png