html - CSS3 中的线性渐变(...)不符合规范?

标签 html css

这是我网页的当前版本:

<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 block 中。但是,当我这样做时,我的颜色变成了深蓝色,我的 0 和 1 变成了白色。

最佳答案

问题是 background: linear-gradient(90, white, #D8D8D8) 中的“90”不正确。根据 W3Schools,它应该是:

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

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

jsFiddle

关于html - CSS3 中的线性渐变(...)不符合规范?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22545524/

相关文章:

PHP 显示由 3 个 CSS 列中的两个串联变量组成的 mysql 查询结果

html - 在 HTML 中显示角度符号

javascript - 在 anchor 标记之前附加到 ul

jquery - 动态生成的 HTML/CSS 网页,将鼠标悬停在表格中时会调整其大小

html - 在另一个 div 下滚动一个 div

html - uib-tab 对齐问题

css - Bootstrap 4 - 折叠外的导航栏元素

php - 修复 HTML 片段

html - 下划线格式问题

html - 如何仅在页面中隐藏菜单栏