8、連續(xù)的圖像邊框

使用圖片當(dāng)做邊框的原理:將圖片設(shè)為背景,在圖片的上方疊加一層內(nèi)容區(qū)域背景色的漸變。并給兩個(gè)背景指定不同的background-clip值。

padding: 1em;
border: 1em solid transparent; //透明的邊框使得能看見底部的背景圖片
background: linear-gradient(white,white),
            url("kazusa.png");
background-size: cover; //將整張圖片適應(yīng)盒子的大小
background-clip: padding-box,border-box; //不同的值使得渲染兩層背景的顯示位置不同。
background-origin: border-box; //圖片默認(rèn)是從padding位置開始渲染,將背景圖片設(shè)為從border區(qū)域開始渲染。這樣border的透明區(qū)域就不會(huì)出線圖片拼接的怪異樣式。

使用這一技巧還可以實(shí)現(xiàn)類似信封樣式的邊框。

padding: 1em;
border: 1em solid transparent;
background: linear-gradient(white,white) padding-box,
            repeating-linear-gradient(-45deg,red 0,red 12.5%,transparent 0,transparent 25%,#58a 25%,#58a 37.5%,transparent 0,transparent 50%);
background-size: 100%,40px 40px;


給漸變邊框加上動(dòng)畫,還可以實(shí)現(xiàn)螞蟻線效果。
演示地址:http://runjs.cn/code/y5fh1hlp


2、腳注效果

在border-image屬性中使用漸變可以實(shí)現(xiàn)文字的腳注效果。

border-top:  3px solid transparent;
border-image: 100% 0 0 linear-gradient(90deg,currentColor 3em,transparent 0);
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容