CSS 谷歌浏览器背景渐变

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6788749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:04:04  来源:igfitidea点击:

Google Chrome background-gradient

cssgoogle-chromelinear-gradients

提问by rickyduck

Really amateur question here - body background-gradient isn't working in chrome, very strange, I've tried:

这里真的是个业余问题 - body background-gradient 在 chrome 中不起作用,很奇怪,我试过:

background: -webkit-gradient(linear, 0 0, 0 bottom, from(#FFF), to(#000));

And

background: -webkit-gradient(linear, 0%, 0%, 0%, 100%, from(#fff), to(#000));

And

background: -webkit-gradient(linear, center top, center bottom, from(#fff), to(#000));

All to no avail! Works in every other browser...

一切都无济于事!适用于所有其他浏览器...

回答by robertc

Have you tried:

你有没有尝试过:

background: -webkit-linear-gradient(#917c4d, #ffffff);

WebKit updated to match the spec syntax, so you should have this to get maximum browser support:

WebKit 已更新以匹配规范语法,因此您应该拥有它以获得最大的浏览器支持

background: -webkit-gradient(linear, center top, center bottom, from(#917c4d), to(#ffffff));
background: -webkit-linear-gradient(#917c4d, #ffffff);
background: -moz-linear-gradient(#917c4d, #ffffff);
background: -o-linear-gradient(#917c4d, #ffffff);
background: -ms-linear-gradient(#917c4d, #ffffff);
background: linear-gradient(#917c4d, #ffffff);

回答by dav

CSS3 linear-gradient tag is now supported by all major browsers.

所有主流浏览器现在都支持 CSS3 linear-gradient 标签。

The syntax requires an additional to. Therefore instead of e.g. center top, left topetc use e.g. to toplike

语法需要额外的to. 因此,而不是 eg center topleft topetc 使用 eg to toplike

background-image: linear-gradient(to top , #094F86, #4EABDB);

回答by David K.

Have you tried this:

你有没有试过这个:

<style>
.myawesomegradient{
background:-webkit-gradient(linear, left top, right top, color-stop(0%,#ffffff), color-stop(100%,#000000));
}
</style>

Should work in Safari and Chrome ...

应该在 Safari 和 Chrome 中工作......