如何在多背景下使用Vendor Properties?

发布于 2024-08-27 17:16:34 字数 360 浏览 15 评论 0原文

我想在css中使用多个背景,目前Firefox 3.61、Chrome/Safari、据说是Opera10.5(不能在gnu/linux上运行)都支持这些背景。它工作正常,但是我想使用线性渐变作为背景。它适用于 Firefox,但不适用于 Chrome,但我不知道如何让它同时适用于两者。。 有什么线索吗? http://snook.ca/archives/html_and_css/multiple-bg-css-渐变 最接近我需要的,但我还无法让它与 chrome 一起使用。

I want to use multiple backgrounds in css, which are currently supported by Firefox 3.61, Chrome/Safari, supposedly Opera10.5 (doesn't run on gnu/linux). It is working fine, however i would like to use linear-gradients as a background. it works ok for Firefox, doesn't work at all with Chrome, yet i can't figure out how to make it work for both at the same time.
any clues?
http://snook.ca/archives/html_and_css/multiple-bg-css-gradients came the closest to match what i need, but i couldn't get it to work with chrome yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你好,陌生人 2024-09-03 17:16:34

我不太肯定,但我的猜测是 chrome 还不支持这一点。虽然一个元素上的多个背景图像和 CSS 渐变听起来不错,但我仍然建议使用多个元素,每个元素各有一个背景图像。由于某些原因,仍然有人使用对 CSS3 不友好的 IE。

I'm not positive, but my guess is that chrome just doesn't support that yet. Although multiple background images and css gradients on one element sure sounds nice, I would still recommend using multiple elements with one background image each. For some reason, there are still people out there who use IE which is not CSS3 friendly at all.

我还不会笑 2024-09-03 17:16:34

这对我有用。看来将 mozilla 放在 webkit 之后会使 webkit 承认背景图像的第二个参数的存在并取消其旧声明。所以我将 -moz 声明放在 -webkit 之前。

  background-image: url("../images/block_stripe_bg.png"); /* for older browsers */
  background-image: url("../images/block_stripe_bg.png"), -moz-linear-gradient(center top, white, #dddddd); /* works for mozilla, ignored by other browsers */
  background-image: url("../images/block_stripe_bg.png"), -webkit-gradient(linear, center top, center bottom, from(white), to(#dddddd)); /* works for webkit, ignored by other browsers */
  background-repeat: repeat; /* older browsers */
  background-repeat: repeat, no-repeat; /* newer browsers should apply this to both backgrounds*/

this worked for me. it seems that placing mozilla after webkit makes webkit acknowledge the existence of a second parameter for background-image and unset its older declaration. so i'm placing the -moz declaration before -webkit.

  background-image: url("../images/block_stripe_bg.png"); /* for older browsers */
  background-image: url("../images/block_stripe_bg.png"), -moz-linear-gradient(center top, white, #dddddd); /* works for mozilla, ignored by other browsers */
  background-image: url("../images/block_stripe_bg.png"), -webkit-gradient(linear, center top, center bottom, from(white), to(#dddddd)); /* works for webkit, ignored by other browsers */
  background-repeat: repeat; /* older browsers */
  background-repeat: repeat, no-repeat; /* newer browsers should apply this to both backgrounds*/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文