css3實現的毛玻璃效果程式碼例項

admin發表於2017-02-28

毛玻璃大家自然都知道怎麼回事。

用css3也可以模擬實現此效果,程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
.container {
  width: 287px;
  height: 285px;
  background-image: url(demo/CSS/img/glass.jpg);
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow: hidden;
}
.frosted-glass {
  width: 287px;
  height: 285px;
  background: inherit;
  -webkit-filter: blur(5px);
  -moz-filter: blur(5px);
  -ms-filter: blur(5px);
  filter: blur(5px);
  filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=4, MakeShadow=false);
}
.weather {
  width: 80px;
  height: 80px;
  margin-top: -200px;
  margin-left: 100px;
  position: relative;
  display: block;
}
</style>
</head>
<body>
  <div class="container">
    <div class="frosted-glass"></div>
    <img class='weather' src="demo/CSS/img/wether.jpg" />
  </div>
</body>
</html>

相關文章