css3 - 如何實(shí)現(xiàn)字體顏色漸變?
問(wèn)題描述
問(wèn)題解答
回答1:先看效果:
直接用photoshop cc畫(huà)出來(lái),圖層單擊右鍵可復(fù)制SVG或者CSS樣式。
方法二:思路:先設(shè)置背景色漸變——規(guī)定背景的劃分區(qū)域——保險(xiǎn)一點(diǎn)再設(shè)置(text-fill-color會(huì)覆蓋color所定義的字體顏色)
/* 這個(gè)文字效果只在webkit內(nèi)核的瀏覽器上才能正常工作。Firefox 瀏覽器不支持在文字上使用background-clip屬性 */h1.start-gradient { font-weight: bold; font-family: helvetica; text-align:center; background: -webkit-linear-gradient(left, #4f185d , #fe5d4b); /* 背景色漸變 */ -webkit-background-clip: text; /* 規(guī)定背景的劃分區(qū)域 */ -webkit-text-fill-color: transparent; /* 防止字體顏色覆蓋 */}<h1 class='start-gradient'>快速開(kāi)始</h1>回答2:
<span class='gradient'>快速開(kāi)始</span>
.gradient { display: inline-block; font-size: 60px; font-family: ’microsoft yahei’; background-image: -webkit-gradient(linear, left center, right center, from(rgba(176, 31, 184, 1)), to(rgba(255, 89, 76, 1))); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}; 回答3:
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {
.masked{ background-image: -webkit-linear-gradient(left, #147B96, #E6D205 25%, #147B96 50%, #E6D205 75%, #147B96); -webkit-text-fill-color: transparent; -webkit-background-clip: text; -webkit-background-size: 200% 100%; -webkit-animation: masked-animation 4s infinite linear;}
}@-webkit-keyframes masked-animation {
0% { background-position: 0 0;}100% { background-position: -100% 0;}
}
相關(guān)文章:
1. 數(shù)組按鍵值封裝!2. docker不顯示端口映射呢?3. python - django 使用 redirect 跳轉(zhuǎn)網(wǎng)頁(yè),怎么傳遞 referer 給目標(biāo)網(wǎng)頁(yè)4. python - SQLAlchemy 向?qū)?yīng)的id插入數(shù)據(jù)怎么操作?5. win10 python3.5 matplotlib使用報(bào)錯(cuò)6. 網(wǎng)頁(yè)爬蟲(chóng) - python 爬蟲(chóng)怎么處理json內(nèi)容7. javascript - 微信小程序電商務(wù)搜索頁(yè)排序功能的邏輯8. python - flask用ajax做后臺(tái)登陸交互,驗(yàn)證密碼后,如何重新定位到index.html上?9. python中def定義的函數(shù)加括號(hào)和不加括號(hào)的區(qū)別?10. mysql 新增用戶(hù) 主機(jī)名設(shè)定 失敗
