|
導讀網頁的本質就是超級文本標記語言,通過結合使用其他的Web技術(如:腳本語言、公共網關接口、組件等),可以創造出功能強大的網頁。因而,超級文本標記語言是萬維網(Web)編程的基礎,也就是說萬維網是建立... 網頁的本質就是超級文本標記語言,通過結合使用其他的Web技術(如:腳本語言、公共網關接口、組件等),可以創造出功能強大的網頁。因而,超級文本標記語言是萬維網(Web)編程的基礎,也就是說萬維網是建立在超文本基礎之上的。超級文本標記語言之所以稱為超文本標記語言,是因為文本中包含了所謂“超級鏈接”點。 本篇文章給大家帶來的內容是關于如何使用CSS實現漸變色動畫邊框的效果(附代碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。效果預覽
源代碼下載https://github.com/comehope/front-end-daily-challenges/tree/master/016-colorful-gradient-animated-border 代碼解讀定義 dom,一個容器中包含一些文字: <div class="box">
you are my<br>
FAVORITE
</div>居中顯示: html,
body,
.box {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}設置頁面背景色: body {
background: #222;
}設置容器和文字樣式: .box {
color: white;
font-size: 2.5em;
width: 10em;
height: 5em;
background: #111;
font-family: sans-serif;
line-height: 1.5em;
text-align: center;
border-radius: 0.2em;
}用偽元素增加一個背板: .box {
position: relative;
}
.box::after {
content: '';
position: absolute;
width: 102%;
height: 104%;
background-color: orange;
z-index: -1;
border-radius: 0.2em;
}把背板設置為漸變色的: .box::after {
/*background-color: orange;*/
background-image: linear-gradient(60deg, aquamarine, cornflowerblue, goldenrod, hotpink, salmon, lightgreen, sandybrown, violet);
}為背板設置動畫效果: .box::after {
background-size: 300%, 300%;
animation: animate_bg 5s ease infinite alternate;
}
@keyframes animate_bg {
0% {
background-position: 0%, 50%;
}
50% {
background-position: 100%, 50%;
}
100% {
background-position: 0%, 50%;
}
}最后,再為文字增加變色效果: .box {
animation: animate_text 2s linear infinite alternate;
}
@keyframes animate_text {
from {
color: lime;
}
to {
color: yellow;
}
}大功告成! 相關推薦: 以上就是如何使用CSS實現漸變色動畫邊框的效果(附代碼)的詳細內容,更多請關注php中文網其它相關文章! 網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。 |
溫馨提示:喜歡本站的話,請收藏一下本站!