加上js代码就可以了
html代码
<span id="blink">闪烁文字</span>
JavaScript代码:
<script type = "text/javascript" >
function blinklink() {
if (!document.getElementById('blink').style.color) {
document.getElementById('blink').style.color = "red"
}
if (document.getElementById('blink').style.color == "red") {
document.getElementById('blink').style.color = "black"
} else {
document.getElementById('blink').style.color = "red"
}
timer = setTimeout("blinklink()", 100)
}
function stoptimer() {
clearTimeout(timer)
}
blinklink()
</script>
<!doctype html><html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
background-color: #000
text-shadow: 2px 3px 10px #FF1717
font-size: 60px
font-weight:bold
transition: color 1s
color: #000
}
.color {
color: #fff
}
</style>
</head>
<body>
<div>我会一闪一闪的</div>
<script>
setInterval(function () {
if (!document.body.className) {
document.body.className = 'color'
} else {
document.body.className = ''
}
}, 500)
</script>
</body>
</html>
我是新手,我觉得可以考虑点击的时候,用 position来控制文字往上移动来实现。:active {
position: relative
top: -10px
}