css可以让网页文字闪烁吗?

html-css08

css可以让网页文字闪烁吗?,第1张

这句css代码就是文字闪烁text-decoration:blink不过很可惜,IE、Chrome 或 Safari 不支持 "blink" 属性值,所以只有在 Firefox 和 Opera 下支持这 CSS 实现在闪动效果。

加上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

}