指引网

当前位置: 主页 > 网页制作 > HTML >

html5+css3网页模糊图片效果简单例子

来源:网络 作者:佚名 点击: 时间:2017-07-06 20:56
[摘要]  模糊图片效果在一些比较喜欢玩时尚的网站都会有的,最初使用的是flash 或者js来实现,现在的css3或html5完全可以达到我们的需求了,下面来看两个例子。

效果如下


例子1

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>html5+css3网页模糊图片效果简单例子-webkfa.com</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <style type="text/css">
     .blur{ 
      filter: url(blur.svg#blur); /* FireFox, Chrome, Opera */
      -webkit-filter: blur(10px); /* Chrome, Opera */
         -moz-filter: blur(10px);
          -ms-filter: blur(10px);   
              filter: blur(10px);   
      filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=10, MakeShadow=false); /* IE6~IE9 */
  }
    </style>
  </head>
 
  <body>
   <img src="/userpl2013/63/59/1427257300357_52816163b.jpg"/><br/>
   <img src="/userpl2013/63/59/1427257300357_52816163b.jpg" class="blur"/>
  </body>
</html>

例子2

<!DOCTYPE html>
<html>
<head> 
  <title>css3图片过滤效果 </title>
  <style>
    body{
      background: #eee;
    }

    .gallery{
      list-style: none;
      margin: 50px auto; padding: 0;
      width: 642px; /* (200+10+4)x3 */
      font-size: 0; /* fix inline-block spacing */
    }

    .gallery li{
        display: inline-block;
        *display: inline;
        zoom: 1;
        width: 200px; height: 150px;
        margin: 2px;
        border: 5px solid #fff;
        -moz-box-shadow: 0 2px 2px rgba(0,0,0,.1);
        -webkit-box-shadow: 0 2px 2px rgba(0,0,0,.1);
        box-shadow: 0 2px 2px rgba(0,0,0,.1);
        -webkit-transition: all .3s ease;
        -moz-transition: all .3s ease;
        -ms-transition: all .3s ease;
        -o-transition: all .3s ease;
        transition: all .3s ease;       
    }

    .gallery:hover li:not(:hover){      
        -webkit-filter: blur(2px) grayscale(1);
        -moz-filter: blur(2px) grayscale(1);
        -o-filter: blur(2px) grayscale(1);
        -ms-filter: blur(2px) grayscale(1);
        filter: blur(2px) grayscale(1);
        opacity: .7; /* fallback */       
    }

    /* Demo page only */
    #about{
        color: #999;
        text-align: center;
        font: 0.9em Arial, Helvetica;
    }

    #about a{
        color: #777;
    }  
  </style>
</head>

<body>


  <ul class="gallery">
      <li><img src="1.jpg"></li>
      <li><img src="2.jpg"></li>
      <li><img src="3.jpg"></li>
      <li><img src="4.jpg"></li>
      <li><img src="5.jpg"></li>
      <li><img src="6.jpg"></li>     
  </ul>

</body>
</html>

------分隔线----------------------------