栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

CSS3打造磨砂玻璃背景效果

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

简介

这个效果是在看CSS Secrets这书上看到的,感觉很不错;

实现原理也挺简单的;

效果图及实现

效果图

代码实现

CSS Code复制内容到剪贴板
  1.   
  2.   
  3.        
  4.            
  5.         document   
  6.            
  7.                       
  8.                     body {   
  9.                           
  10.                         background: url(demo.jpg) no-repeat center center fixed;   
  11.                         background-size: cover;   
  12.                          min-height: 100vh;   
  13.                         box-sizing: border-box;   
  14.                         margin: 0;   
  15.                         padding-top: calc(50vh - 6em);   
  16.                         font: 150%/1.6 Baskerville, Palatino, serif;   
  17.                     }   
  18.   
  19.                       
  20.                     .description{   
  21.                         position: relative;   
  22.                         margin: 0 auto;   
  23.                         padding: 1em;   
  24.                         max-width: 23em;   
  25.                         background: hsla(0,0%,100%,.25) border-box;   
  26.                         overflow: hidden;   
  27.                         border-radius: .3em;   
  28.                         box-shadow: 0 0 0 1px hsla(0,0%,100%,.3) inset,   
  29.                                     0 .5em 1em rgba(0, 0, 0, 0.6);   
  30.                         text-shadow: 0 1px 1px hsla(0,0%,100%,.3);   
  31.                     }   
  32.   
  33.                       
  34.                     .description::before{   
  35.                         content: '';   
  36.                         position: absolute;   
  37.                         top: 0; rightright: 0; bottombottom: 0; left: 0;   
  38.                         margin: -30px;   
  39.                         z-index: -1;   
  40.                         -webkit-filter: blur(20px);   
  41.                         filter: blur(20px);   
  42.                     }   
  43.            
  44.        
  45.        
  46.            
  47.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod   
  48.         tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,   
  49.         quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo   
  50.         consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse   
  51.         cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non   
  52.         proident, sunt in culpa qui officia deserunt mollit anim id est laborum.   
  53.         

      
  54.        
  55.   

总结

这种实现模式是考虑了性能来写的,以及维护上的考虑
- 比如使用了em,可以很轻松的放大缩小整体大小
- 这里使用了hsla,这是我第一次使用这个颜色值;以前只在ps调整这个,很不错的颜色模式.和RGBA大同小异,但是HSLA更符合人类眼睛的观看;
- 还学到了一种新的背景缩写方式

CSS Code复制内容到剪贴板
  1.   
  2. background-color:#ff0;   
  3. background-image:url(background.gif);   
  4. background-repeat:no-repeat;   
  5. background-attachment:fixed;   
  6. background-position:0 0;   
  7. background-size:cover;   
  8.   
  9.   
  10. background: #ff0 url(background.gif) no-repeat / fixed cover;   
  11.   

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/215628.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号