html中文字闪烁效果代码是什么呢?

html-css022

html中文字闪烁效果代码是什么呢?,第1张

javasript代码

<divid="blink">闪烁的文字</div>

<scriptlanguage="javascript">

functionchangeColor(){

varcolor="#f00|#0f0|#00f|#880|#808|#088|yellow|green|blue|gray"

color=color.split("|")

document.getElementById("blink").style.color=color[parseInt(Math.random()*color.length)]

}

setInterval("changeColor()",200)

</script>

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

给需要的对象加上对称标记,就是您需要展示效果的几个文字。如:<html><head><title></title></head><body>

<a href="#" onmouseover="this.style.fontSize='20px'" onmouseout="this.style.fontSize='12px'">动态文本</a>

</body>

</html>

<!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>