【发布时间】:2011-09-15 07:35:56
【问题描述】:
我有一个需要扩展宽度和高度的 html 页面,因此需要能够上下左右滚动,但是我似乎无法让 css 渐变重复-x 并留下一个实心向下着色。
精简代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<style type="text/css" media="screen">
html {
height: 100%;
background-color: #366fcd; }
body {
margin: 0;
height: 100%;
width: 100%;
background-color: #366fcd;
background: -moz-linear-gradient(center top, #316494 0%,#366fcd 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #316494),color-stop(1, #366fcd));
background-repeat: repeat-x;
}
div#TheElement {
position: absolute;
width: 100px;
height: 100px;
background-color: #fff;
left: 2000px;
top: 2000px;
}
</style>
</head>
<body>
<div id="TheElement">
</div>
</body>
</html>
当您向下滚动时,这会将渐变变为纯色 (#366fcd),但当您向右滚动时,渐变会停止并且您也会在那里看到纯色。 See example.
如果我删除 background-color: #366fcd; } 来自 html 元素,然后渐变会按预期沿 x 轴重复,但是当您向下滚动时,渐变会停止并出现白色。 See example.
我知道我总是可以使用背景图片,但更愿意让 CSS 正常工作。
哦,是的,这是在 OSX Lion 上的 Chrome 和 FF 中测试的。
安东尼
【问题讨论】: