1. 程式人生 > >text-stroke實現文字描邊(鏤空)、text-fill-color實現文字填充&漸變(+animation實現流光字體)

text-stroke實現文字描邊(鏤空)、text-fill-color實現文字填充&漸變(+animation實現流光字體)

stroke 顏色 width mas key ani kit mat idt

text-stroke:<‘ text-stroke-width ‘> || <‘ text-stroke-color ‘>(text-stroke-width:設置或檢索對象中的文字的描邊厚度、text-stroke-color:設置或檢索對象中的文字的描邊顏色)

<h2 id="demo">這是描了1像素的文字</h2>
#demo{
    color:#555;
    -webkit-text-stroke:1px #f00;
    -webkit-animation:cliptext 7.5s linear infinite;
}
@-webkit-keyframes cliptext
{ 0%{-webkit-text-stroke:1px #c00;} 25%{-webkit-text-stroke:1px #ff0;} 50%{-webkit-text-stroke:1px #090;} 75%{-webkit-text-stroke:1px #00f;} 100%{-webkit-text-stroke:1px #93c;} }

text-fill-color:<color><color>:指定文字的填充顏色。)

<div class="masked">這是一段漸變(流光)文字</div>
.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 3s infinite linear; } @-webkit-keyframes masked-animation
{ 0% { background-position: 0 0;} 100% { background-position: -100% 0;} }

目前僅webkit核心的瀏覽器下支持此屬性

text-stroke實現文字描邊(鏤空)、text-fill-color實現文字填充&漸變(+animation實現流光字體)