日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > CSS >内容正文

CSS

html怎么做模糊条纹,如何使用纯CSS实现彩虹条纹文字的效果

發布時間:2023/12/10 CSS 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html怎么做模糊条纹,如何使用纯CSS实现彩虹条纹文字的效果 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

源代碼下載

https://github.com/comehope/front-end-daily-challenges

代碼解讀

定義dom,容器中包含文本,并且包含4個用于特效,的data-text屬性值為與文本相同:

web

居中顯示:

html,body{

height:100%;

display:flex;

align-items:center;

justify-content:center;

background:black;

}

定義文本樣式:

.rainbow{

color:white;

font-size:300px;

text-transform:uppercase;

font-family:sans-serif;

font-weight:bold;

line-height:1em;

position:relative;

}

用偽元素增加圖層,形成彩虹效果:

.rainbowspan::before,

.rainbowspan::after{

content:attr(data-text);

position:absolute;

top:0;

left:0;

overflow:hidden;

}

.rainbowspan:nth-child(1)::before{

color:orchid;

z-index:1;

height:calc(100%-10%*1);

}

.rainbowspan:nth-child(1)::after{

color:mediumpurple;

z-index:2;

height:calc(100%-10%*2);

}

.rainbowspan:nth-child(2)::before{

color:deepskyblue;

z-index:3;

height:calc(100%-10%*3);

}

.rainbowspan:nth-child(2)::after{

color:cyan;

z-index:4;

height:calc(100%-10%*4);

}

.rainbowspan:nth-child(3)::before{

color:mediumspringgreen;

z-index:5;

height:calc(100%-10%*5);

}

.rainbowspan:nth-child(3)::after{

color:yellow;

z-index:6;

height:calc(100%-10%*6);

}

.rainbowspan:nth-child(4)::before{

color:gold;

z-index:7;

height:calc(100%-10%*7);

}

.rainbowspan:nth-child(4)::after{

color:tomato;

z-index:8;

height:calc(100%-10%*8);

}

增加動畫效果:

.rainbowspan::before,

.rainbowspan::after{

animation:animate0.8sinfinitealternate;

filter:opacity(0);

}

@keyframesanimate{

from{

filter:opacity(0);

}

to{

filter:opacity(1);

}

}

為圖層設置延時,增強動感:

.rainbowspan:nth-child(1)::before{

animation-delay:calc(0.8s-0.1s*1);

}

.rainbowspan:nth-child(1)::after{

animation-delay:calc(0.8s-0.1s*2);

}

.rainbowspan:nth-child(2)::before{

animation-delay:calc(0.8s-0.1s*3);

}

.rainbowspan:nth-child(2)::after{

animation-delay:calc(0.8s-0.1s*4);

}

.rainbowspan:nth-child(3)::before{

animation-delay:calc(0.8s-0.1s*5);

}

.rainbowspan:nth-child(3)::after{

animation-delay:calc(0.8s-0.1s*6);

}

.rainbowspan:nth-child(4)::before{

animation-delay:calc(0.8s-0.1s*7);

}

.rainbowspan:nth-child(4)::after{

animation-delay:calc(0.8s-0.1s*8);

}

最后,把原始文本設置為透明色:

.rainbow{

color:transparent;

}

大功告成!

本文轉載自中文網

總結

以上是生活随笔為你收集整理的html怎么做模糊条纹,如何使用纯CSS实现彩虹条纹文字的效果的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。