这是我网页的当前版本:
<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);
关于html - CSS3 中的线性渐变(...)不符合规范?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22545524/