box-shadow單邊陰影的實(shí)現(xiàn)

box-shadow 參數(shù)說明
box-shadow: h-shadow v-shadow blur spread color inset
h-shadow(X軸)必需
第一個(gè)長度值指明了陰影水平方向的偏移,即陰影在 x 軸的位置。值為正數(shù)時(shí),陰影在元素的右側(cè);值為負(fù)數(shù)時(shí),陰影在元素的左側(cè)。
v-shadow(Y軸)必需
第二個(gè)長度值指明了陰影豎直方向的偏移,即陰影在 y 軸的位置。值為正數(shù)時(shí),陰影在元素的下方;值為負(fù)數(shù)時(shí),陰影在元素的上方。
blur(模糊距離)可選
第三個(gè)長度值代表了陰影的模糊半徑,舉例來說,就是你在設(shè)計(jì)軟件中使用高斯模糊濾波器帶來的效果。值為 0 意味著該陰影是固態(tài)而鋒利的,完全完全沒有模糊效果。blur 值越大,陰影則更不鋒利而更朦朧 / 模糊。負(fù)值是不合法的,會(huì)被修正成 0。
spread(陰影范圍)可選
第四個(gè)長度代表了陰影擴(kuò)展半徑,其值可以是正負(fù)值,如果值為正,則整個(gè)陰影都延展擴(kuò)大,反之值為負(fù)值是,則縮小。
color (陰影的顏色) 可選
inset (內(nèi)部陰影) 可選
box-shadow 四邊陰影單獨(dú)設(shè)置
<html> <style> .box-shadow-top{ box-shadow: 0 -1px; /* 上外陰影,y坐標(biāo)向上偏移,x不偏移 */ } .box-shadow-bottom{ box-shadow: 0 1px; /* 下外陰影 */ } .box-shadow-left{ box-shadow: -1px 0; /* 左外陰影 */ } .box-shadow-right{ box-shadow: 1px 0 ; /* 右外陰影 */ } .box-shadow-top-inset{ box-shadow:inset 0 1px; /* 上內(nèi)陰影 */ } .box-shadow-bottom-inset{ box-shadow:inset 0 -1px; /* 下內(nèi)陰影 */ } .box-shadow-left-inset{ box-shadow:inset 1px 0; /* 左內(nèi)陰影 */ } .box-shadow-right-inset{ box-shadow:inset -1px 0 ; /* 右內(nèi)陰影 */ } .left{ display:inline-block; background-color: antiquewhite; width: 100px; height: 100px; } div{ margin: 5px ; line-height: 100px; text-align: center; } </style> <body> <div> <div class="box-shadow-top left"> 上外陰影 </div> <div class="box-shadow-bottom left"> 下外陰影 </div> <div class="box-shadow-left left"> 左外陰影 </div> <div class="box-shadow-right left"> 右外陰影 </div> </div> <div> <div class="box-shadow-top-inset left"> 上內(nèi)陰影 </div> <div class="box-shadow-bottom-inset left"> 下內(nèi)陰影 </div> <div class="box-shadow-left-inset left"> 左內(nèi)陰影 </div> <div class="box-shadow-right-inset left"> 右內(nèi)陰影 </div> </div> </body> </html>
設(shè)置效果如下:
陰影的顏色通常是使用純色,當(dāng)然也可以使用漸變色。
到此這篇關(guān)于box-shadow單邊陰影的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)box-shadow單邊陰影內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
相關(guān)文章
css3 box-shadow陰影(外陰影與外發(fā)光)圖示講解
這篇文章主要介紹了css3 box-shadow陰影(外陰影與外發(fā)光),通過五個(gè)測試通過圖片展示了陰影的不同位置不同效果,需要的朋友可以參考下2017-08-11詳解CSS3陰影 box-shadow的使用和技巧總結(jié)
這篇文章主要介紹了詳解CSS3陰影 box-shadow的使用和技巧總結(jié) ,具有一定的參考價(jià)值,有需要的可以了解一下。2016-12-03詳解CSS3的box-shadow屬性制作邊框陰影效果的方法
這篇文章主要介紹了CSS3的box-shadow屬性制作邊框陰影效果的方法,box-shadow屬性還是十分強(qiáng)大的,能設(shè)定陰影的水平或垂直位置,以及陰影的顏色和尺寸等,需要的朋友可以參考下2016-05-10