1. <style>
    2. .tudou {
    3. position: relative;
    4. width: 444px;
    5. height: 320px;
    6. background-color: pink;
    7. margin: 30px auto;
    8. }
    9. .tudou img {
    10. width: 100%;
    11. height: 100%;
    12. }
    13. .tudou::before {
    14. content: '';
    15. /* 隐藏遮罩层 */
    16. display: none;
    17. position: absolute;
    18. top: 0;
    19. left: 0;
    20. width: 100%;
    21. height: 100%;
    22. background: rgba(0, 0, 0, .4) url(../伪元素选择器/arr.png) no-repeat center;
    23. }
    24. /* 当我们鼠标经过了 土豆这个盒子,就让里面before遮罩层显示出来 */
    25. .tudou:hover::before {
    26. /* 而是显示元素 */
    27. display: block;
    28. }
    29. </style>
    30. </head>
    31. <body>
    32. <div class="tudou">
    33. <img src="../伪元素选择器/girl.jpeg" alt="">
    34. </div>
    35. <div class="tudou">
    36. <img src="../伪元素选择器/girl.jpeg" alt="">
    37. </div>
    38. <div class="tudou">
    39. <img src="../伪元素选择器/girl.jpeg" alt="">
    40. </div>
    41. <div class="tudou">
    42. <img src="../伪元素选择器/girl.jpeg" alt="">
    43. </div>
    44. </body>

    image.png