当前位置: 移动技术网 > IT编程>网页制作>HTML > 利用伪元素来做鼠标经过有遮罩层的效果(98)

利用伪元素来做鼠标经过有遮罩层的效果(98)

2020年07月07日  | 移动技术网IT编程  | 我要评论

 

<!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></title>
  <style>
    .box {
      position: relative;
      width: 200px;
      height: 200px;
      margin: 50px auto;
      background-color: red;
    }

    img {
      height: 100%;
      width: 100%;
    }

    .box::after {

      /* 是否显示 */
      display: none;
      /* content必须要有 */
      content: "";
      /* 进行定位,子绝父相 */
      position: absolute;
      /* 绝对定位是对于最近的有定位的上一级的祖先元素来说的 */
      top: 0px;
      right: 0px;
      /* 加入阴影盒子的大小和阴影的透明度 */
      height: 200px;
      width: 200px;
      background: rgba(117, 71, 71, 0.3);
    }

    .box:hover::after {
      display: block;
    }
  </style>
</head>

<body>
  <div class="box">
    <img src="images/btn.png" alt="">
  </div>
</body>

</html>

 

本文地址:https://blog.csdn.net/weixin_45147894/article/details/107150625

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网