欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Css3新特性應用之視覺效果實例

  發(fā)布時間:2016-12-12 17:13:38   作者:小龍女先生   我要評論
這篇文章主要介紹了Css3新特性應用之視覺效果實例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。

本文介紹了Css3新特性應用之視覺效果,具體有單側(cè)陰影、不規(guī)則投影、染色體效果、毛玻璃效果、折角效果,具體實現(xiàn)如下:

一、單側(cè)陰影

1、box-shadow屬性的應用,格式:h-shadow v-shadow blur spread color inset屬性取值介紹 h-sahdow:水平陰影的位置,允許負值

①v-shadow:垂直陰影的位置,允許負值

②blur:模糊距離

③spread:陰影的尺寸,擴張距離,可以為負數(shù)

④color:陰影的顏色

⑤inset/outset:內(nèi)部或者外部陰影

2、陰影的擴張距離對四邊都有效,不能單獨應用于單邊。

3、box-shadow支持多組值同時生效的設置

示例代碼:

.wrap{
            width: 200px;
            height: 120px;
            background: yellowgreen;
            box-shadow: 2px 0px 4px -2px black,
                        -2px 0px 4px -2px black;
        }

二 、不規(guī)則投影

1、利用border-radius生成的形狀,用投影很好,但是如果加入了偽元素和半透明的裝飾,陰影表現(xiàn)就很不好了,如下情況都會有問題。

① 半透明圖像、背景圖像、或者border-image

②元素設置了點狀、虛線或半透明的邊框,但沒有背景(或者background-clip不是border-box時)

③元素內(nèi)部有小角是用偽元素生成

④通過clip-path生成的形狀

解決辦法:利用svg的drop-shadow來實現(xiàn)

示例代碼:

.wrap{
            width: 200px;
            height: 120px;
            border: 6px dotted yellowgreen;
            --box-shadow: 0px 0px 4px 0px black;
            -webkit-filter: drop-shadow(2px 0px 2px rgba(0,0,0,1))
        }

三、染色體效果

1、基于濾鏡實現(xiàn),應用filter屬性的相關值,調(diào)整圖片的飽合度、亮度等值

2、基于min-blend-mode實現(xiàn),作用:實現(xiàn)元素內(nèi)容與背景以及下面的元素發(fā)生“混合”

3、基本background-blend-mode實現(xiàn),作用:實現(xiàn)背景顏色與背景圖片、背景圖片與圖片的混合

三種情況的示例代碼:

.wrap1{
            width: 200px;
            height: 120px;
            overflow: hidden;
        }
        .wrap1 > img{
            max-height: 100%;
            max-width: 100%;
            -webkit-filter: sepia(1) saturate(4) hue-rotate(150deg);
        }

        .wrap2{
            width: 200px;
            height: 120px;
            background: hsl(335, 100%, 50%);
            overflow: hidden;
        }
        .wrap2 > img{
            height: 100%;
            width: 100%;
            mix-blend-mode: luminosity;
        }

        .wrap3{
            width: 200px;
            height: 120px;
            background-size: cover;
            background-color: hsl(335, 100%, 50%);
            background-image: url("../img/cat.png"); 
            background-blend-mode: luminosity;
        }

四、毛玻璃效果

主要實現(xiàn)原理:內(nèi)容偽元素背景與底層背景相同的圖片;并加上filter:blur模糊濾鏡即可。注意blur不能應用在底層背景,也不能應用在元素的背景上(這樣會地元素本身應用blur模糊,會導致文本看不見),只能就用在偽元素上。

代碼如下:

body{
    background: url("../img/cat.png") no-repeat;
    background-size: cover;
}
.wrap{
    position: relative;
    width: 500px;
    margin: 0px auto;
    padding: 10px;
    line-height: 1.5;
    background: hsla(0, 0%, 100%, .3);
    overflow: hidden;
}
.wrap::before{
    content: '';
    background: url("../img/cat.png") 0/cover fixed;
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    filter: blur(20px);
    z-index: -1;
    margin: -30px;
}

代碼說明:1、body與wrap偽元素都應用相同的背景圖片

2、wrap的background-attachment設置為fixed,讓背景圖不要跟隨滾動一起動

3、wrap偽元素設置為絕對定位,且z-index層級只高于背景

4、利用blur設定wrap偽元素的模糊尺寸

5、用margin負值增加寬度,父元素用overflow:hidden隱藏溢出,讓模糊背景更加真實。

五、折角效果

實現(xiàn)步驟

1、首先利用linear-gradient實現(xiàn)切角效果2、然后再利用linear-gradinet生成一個三角形,并設置他的位置與寬高

代碼如下:

.wrap{
        background: linear-gradient(to left bottom, transparent 50%, rgba(0, 0, 0, .4) 0) no-repeat 100% 0/2em 2em,
        linear-gradient(-135deg, transparent 1.4em, #58a 0);
        width: 200px;
        height: 120px;
    }

注意

1、100% 0/2em 2em在定位背景元素的位置與寬高,尤其是2em的寬與高都是背景元素正常的寬度。

2、而第二個linear-gradient中的1.4em是沿著漸變軸進行度量的,也就是漸變軸到元素頂邊的距離,本例是漸變軸到右上邊頂?shù)木嚯x

3、to left bottom是表示漸變從左下角開始

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論