当前位置: 移动技术网 > IT编程>网页制作>HTML > css3滤镜开发模糊背景效果(99)

css3滤镜开发模糊背景效果(99)

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;
      height: 600px;
      margin: 0px auto;
      background: url(images/1.jpg) no-repeat center;
      background-size: 100% 100%;
      z-index: 1;
    }
.box::after{
  content: "";
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0px;
  left: 0px;
  background: inherit ;
  background-size: 100% 100%;
  filter: blur(11px);
  z-index: 2;
}
p{
  width: 100%;
  position: absolute;
  top:50%;
  text-align: center;
  font-size: 36px;
  color:rgb(8, 8, 8);
  z-index: 3;
}
  </style>
</head>

<body>
  <div class="box">
    <p>总有一些人在等你,沿途风景很美好<br>
      别忘了有人在此等你!
    </p>
  </div>
</body>

</html>

二:如何局部模糊呢?让层级高的盒子在上面变模糊和变小一点,根据自己的需要来进行设置大小: 

代码如下: 

<!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;
      height: 600px;
      margin: 0px auto;
      background: url(images/1.jpg) no-repeat center;
      background-size: 100% 100%;
      z-index: 1;
    }
.box::after{
  content: "";
  width: 300px;
  height: 300px;
  position: absolute;
  top:50%;
  left: 50%;
  margin-left: -150px;
  margin-top: -150px;
  background: inherit ;
  background-size: 100% 100%;
  filter: blur(11px);
  z-index: 2;
}
p{
  width: 100%;
  position: absolute;
  top:50%;
  text-align: center;
  font-size: 36px;
  color:rgb(8, 8, 8);
  z-index: 3;
}
  </style>
</head>

<body>
  <div class="box">
    <p>总有一些人在等你,沿途风景很美好<br>
      别忘了有人在此等你!
    </p>
  </div>
</body>

</html>

 

<!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 {
      height: 600px;
      margin: 0px auto;
      z-index: 1;

    }

    .bg {
      position: relative;
      height: 600px;
      margin: 0px auto;
      background: url(images/1.jpg) no-repeat center;
      background-size: 100% 100%;
      filter: blur(11px);
      z-index: 2;
    }

    .box::after {
      content: "";
      width: 300px;
      height: 300px;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-left: -150px;
      margin-top: -150px;
      background: url(images/1.jpg) no-repeat center;
      background-size: 100% 100%;
      filter: blur(0px);
      z-index: 3;
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="bg">
      总有一些人在等你,沿途风景很美好<br>
        别忘了有人在此等你!
    </div>
  </div>
</body>

</html>

 

 

 

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

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

相关文章:

验证码:
移动技术网