实现代码:

CodePen:毛玻璃效果

Dabblet:毛玻璃效果

HTML:

<main>
<blockquote>
<em>“The only way to get rid of a temptation is to yield to it. Resist it, and your soul grows sick with longing for the things it has forbidden to itself, with desire for what its monstrous laws have made monstrous and unlawful.”</em>
<footer>—
<cite>Oscar Wilde, The Picture of Dorian Gray
</cite>
</footer>
</blockquote>
</main>

CSS:

body {
font: 150%/1.6 Baskerville, Palatino, serif;
} body, main::before {
background: url("http://csssecrets.io/images/tiger.jpg") 0 / cover fixed;
} main{
width: 50%;
background: hsla(0,0%,100%,.3);
position: relative;
margin: 0 auto;
overflow: hidden; // 将溢出的模糊部分隐藏
} main::before {
content: '';
position: absolute;
top: 0; right: 0; bottom: 0; left: 0; // 学习这种一行写法
margin: -30px;
z-index: -1; // 隐藏在main之后
-webkit-filter: blur(20px);
filter: blur(20px);
}

知识点解析

1. CSS 简写

【font 属性】:

font-style: italic;
font-weight: bold;
font-size: .8em;
line-height: 1.2;
font-family: Arial, sans-serif;

可以简写成下面的:

font: italic bold .8em/1.2 Arial, sans-serif;

【background 属性】:

CSS2.1

// 使用的背景颜色
background-color: color;
// 使用的背景图像
background-image: url(...);
// 如何重复背景图像
background-repeat: repeat || repeat-x || repeat-y || no-repeat;
// 背景图像是否固定或者随着页面的其余部分滚动
background-attachment: scroll || fixed || local;
// 背景图像的位置,可以取3种类型的值:length values/percentages/keywords
background-position: 100px 5px || 100% 5% || top right

CSS3

// 背景图片的尺寸:5种语法可使用
background-size: keywords || one-value || two-value || multiple bg || global value
// 背景图片的定位区域,在边框内或者内边距内等
background-origin: border-box || padding-box || cntent-box || inherit;
// 背景的显示区域,已经定好位了,通过边框等进行限制其显示的大小
background-clip: border-box || padding-box || content-box || inherit;

简写方式如下:

background: [background-color] [background-image] [background-repeat] [background-attachment] [background-position] / [ background-size] [background-origin] [background-clip];

具体每个属性的取值请参考 CSS-TRICKSbackground-size--MDN

参考:

CSS 的简写属性-MDN

CSS简写指南

CSS的 background 简写方式

CSS-TRICKS:★

2. 几种色彩表达方式

参考:CSS进阶:CSS 颜色体系详解

一般情况下,前端使用 hsl 表示颜色会更方便,对于按钮颜色深浅的切换只需改一个参数。

在控制台中审查元素时,对于color,按住 Shift 键可以切换颜色的显示方式。

3. filter

CSS-tricks: filter

MDN-filter

《CSS揭秘》之毛玻璃效果知识点的更多相关文章

  1. CSS技巧收集——毛玻璃效果

    先上 demo和 源码 其实毛玻璃的模糊效果技术上比较简单,只是用到了 css 滤镜(filter)中的 blur 属性.但是要做一个好的毛玻璃效果,需要注意很多细节. 比如我们需要将上图中页面中间的 ...

  2. css透明度、毛玻璃效果

    透明度: 1.opacity    背景颜色和字体同时透明 2.background:rgba(255,255,255,0.2);   只是背景颜色透明,字体不透明 代码: .info{ backgr ...

  3. 小tip: 使用CSS将图片转换成模糊(毛玻璃)效果

    去年盛夏之时,曾写过“小tip: 使用CSS将图片转换成黑白”一文,本文的模式以及内容其实走得是类似路线.CSS3 → SVG → IE filter → canvas. 前段时间,iOS7不是瓜未熟 ...

  4. [转] 小tip: 使用CSS将图片转换成模糊(毛玻璃)效果 ---张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=3804 去年盛夏之时, ...

  5. CSS遮罩效果和毛玻璃效果

    前面的话 本文将详细介绍CSS遮罩效果和毛玻璃效果 遮罩效果 普通遮罩 一般地,处理全屏遮罩的方法是使用额外标签 <style>.overlay{ position:fixed; top: ...

  6. 实现一个成熟的底层毛玻璃效果(纯CSS)

    写在前面 毛玻璃背景是一个很常见的网页样式,想要实现,其实并不难,但经过我在网上的搜索发现,大量实现方法都较为不规范,且把问题复杂化了(例如各种z-index属性和position的定位)现提供一个代 ...

  7. css实现毛玻璃效果

    css实现毛玻璃效果,效果图 1,html代码 <div class="mainHolder"> <div class="textHolder" ...

  8. CSS 奇思妙想 | 全兼容的毛玻璃效果

    通过本文,你能了解到 最基本的使用 CSS backdrop-filter 实现磨砂玻璃(毛玻璃)的效果 在至今不兼容 backdrop-filter 的 firefox 浏览器,如何利用一些技巧性的 ...

  9. 【CSS】梯形、平行四边形导航条与毛玻璃效果【转】

    转载出处:http://www.cnblogs.com/Uncle-Keith/p/5943158.html 代码部分有小改动. 导航条对于每一个Web前端攻城狮来说并不陌生,但是毛玻璃可能会相对陌生 ...

随机推荐

  1. shell的交互式和非交互式登录

    工作中经常碰见环境变量加载问题,归根结底就是配置文件的加载问题. 一般会有四种模式:交互式登陆.非交互式登陆.交互式非登陆.非交互非登陆. 交互式和非交互式对环境变量的加载: +----------- ...

  2. centos6.5下安装Redis

    已有redis-3.2.1.tar.gz文件 拖到centos系统的桌面 现在在桌面目录下 tar -zxv -f redis-3.2.1.tar.gz以解压压缩包 cd redis-3.2.1以切换 ...

  3. 如何通过代码设置WPF控件的字体,颜色

    this.lbTips.Foreground = new SolidColorBrush(Colors.Black); this.lbTips.FontFamily = new FontFamily( ...

  4. css基础参考文档

    block inline-block inline区别 absolute定位详解:https://www.jianshu.com/p/a3da5e27d22b css浮动详解 float浮动 div变 ...

  5. SQL Server数据归档的解决方案

    SQL Server数据归档的解决方案   最近新接到的一项工作是把SQL Server中保存了四五年的陈年数据(合同,付款,报销等等单据)进行归档,原因是每天的数据增量很大,而历史数据又不经常使用, ...

  6. composer修改成国内镜像

    因为composer安装包数据是从github.com上下载的,安装包的元数据从packagist.org上下载 作为两个国外的网站,连接速度会很慢,而且很有可能网站被墙. 所以composer中国全 ...

  7. 正则表达式中pw、IDCard和EM匹配

    1密码强度正则 //密码强度正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符 var pPattern = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])( ...

  8. [hdu P4334] Trouble

    [hdu P4334] Trouble Hassan is in trouble. His mathematics teacher has given him a very difficult pro ...

  9. struct放入list中按照某字段排序

    //管线字段信息 public struct FieldInfo { public int iID; //编号 public string sFieldName; //字段名 public strin ...

  10. css3实现自适应的3行,左右行固定宽度,中间自适应,要求先渲染中间部分

    https://blog.csdn.net/thqy39/article/details/73512478 https://www.cnblogs.com/ranzige/p/4097453.html ...