简体   繁体   English

在CSS中的重复Y上翻转背景图片

[英]Flip background image on repeat-y in CSS

I have a gradient image as the background to my website and I am having problems making it look correct with all page sizes. 我有一个渐变图像作为我网站的背景,但是在使所有页面尺寸看起来都正确时遇到了问题。 The image is 291x1080 and I am having it do a repeat-x. 图像为291x1080,我正在执行重复-x。 This is fine with all pages that are no larger than 1080p. 这适用于所有不大于1080p的页面。 However, for a page with more content or a screen with a resolution larger than 1080p, a white space follows the background. 但是,对于具有更多内容的页面或分辨率大于1080p的屏幕,背景后面会有空白。 I do not want to do a simple repeat-y because the gradient going from light to dark without a transition would be strange. 我不想做简单的重复-y,因为从亮到暗的渐变没有过渡会很奇怪。 Is there any way to flip the background image every time it does a repeat-y using CSS? 是否有任何方法可以在每次使用CSS进行重复操作时翻转背景图像?

My suggestion: have the fabric texture and a gradient, not in an image. 我的建议是:不要在图像中显示出织物的质地和渐变感。

For example: 例如:

body{
     background-image: url("/static/img/background.png") repeat, linear-gradient(top, #000000, #123456);
}

You should make sure you add the browser support tags (-webkit, etc) 您应该确保添加浏览器支持标签(-webkit等)

For further reference check out this: How do I combine a background-image and CSS3 gradient on the same element? 作为参考,请检查以下内容: 如何在同一元素上组合背景图像和CSS3渐变?

This is the css to do this: 这是CSS来做到这一点:

body {
    ...
    background: #eeeeee url("/static/img/background.png") 0 0 repeat-x;
    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM