CSS文字高光效果,可以用来当Loading页面
一、利用文字背景
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title></title> <style type="text/css"> * {margin: 0;padding: 0;} .q-loading-2 {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: #ffebeb; display: flex;justify-content: center;align-items: center;} .q-loading-2-inner {font-size: 40px;font-weight: bold;background: #ccc linear-gradient(135deg,transparent 25%,transparent 40%,rgba(255,255,255, 1) 40%, rgba(255,255,255, 1) 60%,transparent 60%, transparent);background-size: 60px 60px;background-repeat: no-repeat; -webkit-background-clip: text;-webkit-text-fill-color: transparent;animation: scratchy 1.5s linear infinite; } @keyframes scratchy { 0% { background-position: -100% 0; } 100% { background-position: 130% 0; } } </style> </head> <body> <div id="app"> <div class="q-loading-2"> <div class="q-loading-2-inner" @click="$t.openHaha"> 系统联盟 </div> </div> </div> </body> </html>
二、利用伪元素
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title></title> <style type="text/css"> * {margin: 0;padding: 0;} .q-loading-3 {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: #ffffff; display: flex;justify-content: center;align-items: center;} .q-loading-3::before {content: '系统联盟';position: absolute;top: 36%;left: 50%;white-space: nowrap; transform: translateX(-50%);height: 50px;color: #d7d7d7;font-size: 36px;font-weight: bold;letter-spacing: 3px;} .q-loading-3::after {content: '';position: absolute;top: 36%;left: 20%; 12px; transform: translateX(-50%);height: 50px;background-color: rgba(255, 255, 255, .5);transform: skew(20deg); animation: 1.8s loadingframe infinite;} @keyframes loadingframe{ from{left: 20%;} to{left: 80%;} } </style> </head> <body> <div id="app"> <div class="q-loading-3"></div> </div> </body> </html>