猿问

关于文字颜色的一个小问题

为什么在span里设置文字颜色没有效果,

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8" />

    <title>显示当前时间.htm</title>

    <style>

        .timer{

            width: 150px;

            height: 20px;

            line-height: 20px;

            background-color: black;

            text-align: center;

            margin: 30px auto;

            /*color: rgb(255,255,255);*/

        }

        .clock{

            

            color: rgb(255,255,255);

        }

    </style>

</head>

<body>

    <div class="timer">

        <span id="clock">1</span>

    </div>

    <script>

    function distime(){


        var elt = document.getElementById("clock")

        var now = new Date();

        elt.innerHTML = now.toLocaleTimeString()

        setTimeout(distime,1000)

    }

        window.onload = distime;

    </script>

</body>

</html>

效果图:

慕哥9229398
浏览 497回答 1
1回答

慕斯王

你给span设置的是id为clock 你css用的点 也就是class 然后就是你没有透明度的话没必要用rgb吧
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答