
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>光标动画</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
html,body{
height: 100%;
overflow: hidden;
background: black;
text-align: center;
}
h1{
margin-top: 50px;
display: inline-block;
color: rgba(255,255,255,.3);
font:bold 80px "微软雅黑";
background: linear-gradient(120deg,rgba(255,255,255,0) 100px,rgba(255,255,255,1) 180px,rgba(255,255,255,0) 270px) no-repeat;
-webkit-background-clip:text;
}
</style>
</head>
<body>
<h1>欢迎来到<阿杰网络科技博客资源站></h1>
</body>
<script type="text/javascript">
var h1 = document.querySelector("h1");
var flag = -160;
setInterval(function(){
flag+=10;
if(flag == 1100){
flag = -160;
}
h1.style.backgroundPosition = flag +"px";
},30);
</script>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号