在Web開發(fā)中,CSS樣式并不只局限于簡單的文本樣式,而在超鏈接的樣式化方面,CSS也可以實(shí)現(xiàn)多樣化的效果,如下述的幾種復(fù)雜CSS超鏈接:
// 1. 邊框漸變效果 a{ background: #FFA6A6; border: 2px solid #FF6464; padding: 10px; color: #fff; background-image: linear-gradient(to bottom, #FFA6A6, #FF6464); transition: ease-out .3s; } a:hover{ background-image: linear-gradient(to bottom, #FF6464, #FFA6A6); } // 2. 彩虹漸變效果 a{ background: #fff; border: 2px solid #1DDB16; display: inline-block; padding: 10px 20px; color: #1DDB16; font-weight: bold; background: linear-gradient(to right, #FF0000, #FF7F00, #FFFF00, #00FF00, #0000FF, #8B00FF); background-size: 150%; background-position: left; transition: background-position .3s; } a:hover{ background-position: right; } // 3. 帶圖標(biāo)的超鏈接 a{ background: #FFD1AE; border: 2px solid #FF9673; padding-left: 30px; position: relative; display: inline-block; color: #fff; } a:before{ content: ""; background-image: url(./icon.png); background-size: cover; height: 20px; width: 20px; position: absolute; top: 50%; left: 10px; transform: translateY(-50%); } a:hover{ background: #FF9673; } // 4. 懸浮效果 a{ color: #fff; text-decoration: none; position: relative; z-index: 1; padding: 5px 20px; display: block; background-color: #6C5CE7; transition: .4s; } a:before{ content: ""; position: absolute; z-index: -1; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 0%; height: 85%; background-color: #FFC751; transition: .4s; } a:hover:before{ width: 85%; }
以上代碼是幾種CSS超鏈接的實(shí)現(xiàn)方法,這或許可以給你的網(wǎng)頁設(shè)計(jì)和開發(fā)帶來靈感。