HTML5文字特效代碼是一種可以讓網(wǎng)頁文本更生動(dòng)、更具有吸引力的技術(shù)。下面是一些常用的HTML5文字特效代碼:
<style> /* 豎直折疊特效 */ .fold { position: relative; overflow: hidden; } .fold::before, .fold::after { content: ""; position: absolute; width: 100%; height: 50%; left: 0; background-color: #333; transform-origin: top; transition: transform .5s; } .fold::before { top: 0; transform: scaleY(0); } .fold::after { bottom: 0; transform: scaleY(1); } .fold:hover::before { transform: scaleY(1); } .fold:hover::after { transform: scaleY(0); } /* 斜角滑動(dòng)特效 */ .slide { display: inline-block; position: relative; z-index: 1; overflow: hidden; padding-top: .25em; } .slide::before, .slide::after { content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: 0; right: 0; background-color: #333; transform: skewX(-30deg) translateX(-100%); transition: transform .5s; } .slide::after { transform: skewX(30deg) translateX(-100%); } .slide:hover::before { transform: skewX(-30deg) translateX(100%); } .slide:hover::after { transform: skewX(30deg) translateX(100%); } /* 漸變特效 */ .gradient { background: linear-gradient(to right, #fff, #f00, #00f, #fff); background-size: 200% 200%; background-position: 0 50%; text-shadow: 0 0 10px rgba(255, 255, 255, .5); -webkit-animation: gradient 10s ease infinite; animation: gradient 10s ease infinite; } @-webkit-keyframes gradient { 0% { background-position: 0 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0 50%; } } @keyframes gradient { 0% { background-position: 0 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0 50%; } } </style> <p class="fold">折疊特效文字</p> <p class="slide">斜角滑動(dòng)特效文字</p> <p class="gradient">漸變特效文字</p>
以上代碼分別實(shí)現(xiàn)了豎直折疊、斜角滑動(dòng)和漸變?nèi)N文字特效。這些代碼可以讓網(wǎng)頁文本更加生動(dòng)有趣,從而吸引用戶的注意力。