如何添加从上到下的背景渐变图像?
body {
color:#999;
background-color:#000;
font-family:"Helvetica Neue", Helvetica, arial, sans-serif;
font-size:11px;
line-height:1.8em;
background-image: url(../images/bck.jpg);
padding:0;
margin:0;
}
我如何修改它以添加从网站顶部到底部的渐变背景图像?
body {
color:#999;
background-color:#000;
font-family:"Helvetica Neue", Helvetica, arial, sans-serif;
font-size:11px;
line-height:1.8em;
background-image: url(../images/bck.jpg);
padding:0;
margin:0;
}
How can i modify it to add a gradient background image from the top to bottom of the site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑它,因为它适合您。
Edit it as it suits you.
Mob 对 CSS3 有一个很好的答案。但是,如果您想使用图像来支持较旧的浏览器,但希望它仅在某个方向上重复,只需使用repeat-x或repeat-y,如下所示:
如果您希望将规则分开,只需添加:
按照你的规则。您还可以根据需要使用“repeat-y”或“no-repeat”。正如您已经看到的,默认行为是全部重复。如果您不担心遗留支持,Mob 的答案是一个很好的选择,因为它不依赖于固定的图像大小,并且无论内容的高度如何,它总是跨越适当的距离。
Mob has a good answer for CSS3. However, if you want to use an image to support older browsers, but want it to repeat in only a certain direction, just use repeat-x or repeat-y, as follows:
If you'd rather keep your rules separate, just add:
to your rules. You can also use 'repeat-y' or 'no-repeat', depending upon your needs. As you saw already, the default behavior is to repeat-all. If you are not worried about legacy support, Mob's answer is a good fit, as it doesn't rely on a fixed image size, and it will always span the proper distance, regardless of the height of your content.