簡體   English   中英

CSS3中的linear-gradient(…)不能按規范工作?

[英]linear-gradient(…) in CSS3 not working according to specifications?

這是我網頁的當前版本:

<html>
<head>
    <title>my site</title>


    <style type="text/css">
        #mtx_bckgd
        {
            font-family: Courier New;
            height: 1000px;
            width: 1000px;
            position: absolute;
            z-index: -1;
        }
        #mtx_bckgd > p
        {
            word-wrap: break-word;
            color: #D8D8D8;     
            overflow: hidden;
        }
        #header
        {
            position: absolute;
            font-family: Trebuchet MS;
            width: 1000px;
            height: 70px;
            text-align: center;
            border: solid 2px #424242;
            top: 25px;
            font-size: 20;
        }
    </style>
    <script type="text/javascript">
        function change_bckgd()
        {
            var bitstr = "";
            for (var i = 0; i < 4000; ++i)
                bitstr += Math.floor(Math.random()*10) % 2 ? "0" : "1";
            document.getElementById("mtx_txt").innerHTML = bitstr;

        }
    </script>


</head>
<body>
    <div id="mtx_bckgd">
        <p id="mtx_txt"></p>
    </div>
    <div id="header">
        <h1>JaminWEB</h1>
    </div>
    <script type="text/javascript">
        setInterval(change_bckgd, 200);
    </script>
</body>
</html>

我打算做的是在背景上創建垂直的淡入淡出,從底部的白色到頂部的淺灰色(與我在背景中用於0和1的灰色相同)。

根據W3schools( http://www.w3schools.com/css/css3_gradients.asp ),語法

background: linear-gradient(angle, color-stop1, color-stop2);

表示我應該添加行

background: linear-gradient(90, white, #D8D8D8)

在樣式表的#mtx_bckgd塊中。 但是,當我這樣做時,我會得到深藍色的淡入淡出,並且我的0和1變成白色。

問題是background: linear-gradient(90, white, #D8D8D8)的“ 90” background: linear-gradient(90, white, #D8D8D8)不正確。 根據W3Schools,它應該是:

background: linear-gradient(90deg, white, #D8D8D8)

要么

background: linear-gradient(to right, white, #D8D8D8);

的jsfiddle

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM