简体   繁体   English

跨浏览器背景图像重复Y渐变

[英]Crossbrowser background-image repeat-y gradient

I have image 1*910px high, I want to make background. 我的图片高1*910px ,我想做背景。

here is my css: 这是我的CSS:

body
{
    background-image:url('/Content/themes/start/images/bgw.png');
    background-position: 50% 100%;
    background-repeat: repeat-x;
    background-color: #e8f3fb;    
    color: #000;
}

If I have page with long content it looks good, but if page does not have long content the background doesn't display correctly. 如果我的页面内容长,看起来不错,但是如果页面内容不长,背景将无法正确显示。

I did try to set min-height , but it is not what I want to achieve. 我确实尝试设置min-height ,但这不是我想要实现的。

Maybe there is some other way of doing this, or if not: how may I fix it? 也许还有其他方法可以做到这一点,如果没有,我该如何解决?

Is there any way to make background more dynamic according to the content size? 有什么方法可以根据内容大小使背景更加动态吗?

Any advice/sample? 有什么建议/样品吗?

You could use a CSS gradient, they're reasonably well-supported now. 您可以使用CSS渐变,它们现在得到了很好的支持。

Eg 例如

Fallback for older browsers 旧版浏览器的后备

background: #333 url(gradient.gif) left top repeat-x;

Firefox, Safari/Chrome, and apparently Opera 11.10 and later Firefox,Safari / Chrome和Opera 11.10及更高版本

(Some earlier Operas support SVG in background images, which is another alternative for gradients , but I'm not sure how well it plays with the other methods. Plus you have to learn some SVG.) (一些早期的Opera 在背景图像中支持SVG,这是渐变的另一种选择 ,但我不确定它在其他方法中的表现如何。此外,您还必须学习SVG。)

background: -moz-linear-gradient(
    top,
    #333 0%,
    #555 100%
);
background: -o-linear-gradient(
    top,
    #333 0%,
    #555 100%
);
background: -webkit-gradient(
    linear,
    left top,
    left bottom,
    color-stop(0%,#333),
    color-stop(100%,#555)
);

IE IE

filter: progid:DXImageTransform.Microsoft.gradient(
    startColorstr='#333333',
    endColorstr='#555555',
    GradientType=0
);

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

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