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

歡迎訪問 生活随笔!

生活随笔

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

CSS

22.纯 CSS 创作出美丽的彩虹条纹文字

發布時間:2024/3/13 CSS 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 22.纯 CSS 创作出美丽的彩虹条纹文字 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
22.純 CSS 創作出美麗的彩虹條紋文字

原文地址:https://segmentfault.com/a/1190000014858628

感想: 利用四個span的::before 和 ::after創出多個WEB,給其顏色,絕對定位,再利用z-index: n;突出顯示的優先級。

HTML代碼:

<html><head><link rel="stylesheet" href="index.css"></head><body><p class="rainbow">web<span data-text="web"></span><span data-text="web"></span><span data-text="web"></span><span data-text="web"></span></p></body> </html>

CSS代碼:

html, body {margin: 0;padding: 0;height: 100%;display: flex;justify-content: center;align-items: center;background: black; } .rainbow {color: white;font-size: 300px;text-transform: uppercase;font-family: sans-serif;font-weight: bold;line-height: 1em;position: relative; } /* 用偽元素增加圖層,形成彩虹效果 */ .rainbow span::before, .rainbow span::after {content: attr(data-text);position: absolute;top: 0;left: 0;overflow: hidden; } .rainbow span:nth-child(1)::before {color: orchid;z-index: 1;height: calc(100% - 10% * 1); } .rainbow span:nth-child(1)::after {color: mediumpurple;z-index: 2;height: calc(100% - 10% * 2); } .rainbow span:nth-child(2)::before {color: deepskyblue;z-index: 3;height: calc(100% - 10% * 3); } .rainbow span:nth-child(2)::after {color: cyan;z-index: 4;height: calc(100% - 10% * 4); } .rainbow span:nth-child(3)::before {color: mediumspringgreen;z-index: 5;height: calc(100% - 10% * 5); } .rainbow span:nth-child(3)::after {color: yellow;z-index: 6;height: calc(100% - 10% * 6); } .rainbow span:nth-child(4)::before {color: gold;z-index: 7;height: calc(100% - 10% * 7); } .rainbow span:nth-child(4)::after {color: tomato;z-index: 8;height: calc(100% - 10% * 8); } /* 增加動畫效果 */ .rainbow span::before, .rainbow span::after {animation: animate 0.8s infinite alternate;filter: opacity(0); } @keyframes animate {from {filter: opacity(0);}to {filter: opacity(1);} } /* 為圖層設置延時,增強動感 */ .rainbow span:nth-child(1)::before {animation-delay: calc(0.8s - 0.1s * 1); } .rainbow span:nth-child(1)::after {animation-delay: calc(0.8s - 0.1s * 2); } .rainbow span:nth-child(2)::before {animation-delay: calc(0.8s - 0.1s * 3); } .rainbow span:nth-child(2)::after {animation-delay: calc(0.8s - 0.1s * 4); } .rainbow span:nth-child(3)::before {animation-delay: calc(0.8s - 0.1s * 5); } .rainbow span:nth-child(3)::after {animation-delay: calc(0.8s - 0.1s * 6); } .rainbow span:nth-child(4)::before {animation-delay: calc(0.8s - 0.1s * 7); } .rainbow span:nth-child(4)::after {animation-delay: calc(0.8s - 0.1s * 8); } /* 最后,把原始文本設置為透明色 */ .rainbow {color: transparent; }

?

posted on 2019-01-14 16:32? 人生與戲 閱讀( ...) 評論( ...) 編輯 收藏

轉載于:https://www.cnblogs.com/FlyingLiao/p/10267593.html

總結

以上是生活随笔為你收集整理的22.纯 CSS 创作出美丽的彩虹条纹文字的全部內容,希望文章能夠幫你解決所遇到的問題。

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