如何将网页CSS背景图高斯模糊且全屏显示

html-css012

如何将网页CSS背景图高斯模糊且全屏显示,第1张

高斯模糊是PS、FW图片处理工具搞的。

全屏显示的方法1:使用CSS

.bg {background-image:url(scale.jpg)

-moz-background-size: 100% 100%/* Firefox 3.6 */

-o-background-size: 100% 100%/* Opera 9.5 */

-webkit-background-size: 100% 100%/* Safari 3.0 */

background-size: 100% 100%/* Firefox 4.0 and other CSS3-compliant browsers */

-moz-border-image: url(scale.jpg) 0/* Firefox 3.5 */

filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='scale.jpg', sizingMethod='scale')/* for <ie9 */}2:使用 IMG 标签

<img class=stock style=position: absolutetop: 0pxleft: 0pxheight: 100%width: 100%src=default.jpg补充方法3:使用 CSS3 的背景 Cover

.bg {background: #000 url(scale.jpg) no-repeat center center

-webkit-background-size: cover

-moz-background-size: cover

<div class="page show-modal">

    <div class="container">主要内容</div>

    <div class="modal">浮层</div>

</div>

假设有这样的HTML结构,那么让 .modal 绝对定位在 .container 上面,.container 设置 blur 即可。

.modal {

    display: none

    position: fixed

    left: 0

    top: 0

    right: 0

    bottom: 0

    background: rgba(255,255,255,.8)

}

.show-modal .modal {

    display: block

}

.show-modal .container {

    -webkit-filter: blur(4px)

}

演示:http://jsbin.com/nesewayosa/1/

filter 属性定义了元素(通常是img)的可视效果(例如:模糊与饱和度)。

语法:

filter: none | blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | url()

使用效果: 查看demo

demo 是我的GitHub主页,当鼠标放在圆形上面的时候,圆形会旋转,这里主要应用了 animation 属性。而绿色圆形的下面那层投影的模糊效果则是运用了下面这条属性:

而完整卡片又该怎么写呢?

首先是它的 <html>结构:

CSS样式:

圆角背景:

圆形样式:

投影层的样式:

文字的样式:

如此,便可不用一张图,写出这张卡片了。