Modernizr 不会向我的 CSS 渐变添加前缀
我正在尝试将 Modernizr 与 css 渐变一起使用。 我读到 Modernizr 现在可以添加前缀。 所以,我在我的 css 文件中设置了这个:
background-image: linear-gradient(top, #FFF, #AAA);
如果我理解这应该转换为:
background-image: -webkit-linear-gradient(top, #FFF, #AAA);
但什么也没有发生,我的渐变也没有显示。这是一个错误还是我错过了什么?
I'm trying to use Modernizr with css gradients.
I've read that Modernizr is now capable to add prefixes.
So, I have set this in my css file:
background-image: linear-gradient(top, #FFF, #AAA);
And if I understand this should be transformed to:
background-image: -webkit-linear-gradient(top, #FFF, #AAA);
But nothing happens and my gradient is not displayed. Is that a bug or am I missing something ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Modernizr 是一个 JavaScript 库。它不会改变 CSS 的行为。如果运行它的浏览器需要的话,Modernizr 中的前缀内容会生成正确的前缀 CSS 属性名称。您的示例代码没有 JavaScript;它只是CSS; Modernizr 不会改变其行为。
Modernizr is a JavaScript library. It will not change the behavior of your CSS. The prefix stuff in Modernizr generates the correctly prefixed CSS property name if it is needed for the browser on which it is running. Your sample code has no JavaScript; it is just CSS; Modernizr won't change its behavior.
Modernizr 不添加供应商前缀。它仅检查浏览器支持的内容。
您可以使用这个 jQuery 插件。
https://github.com/codler/jQuery-Css3-Finalize 它会自动添加供应商前缀。但它对线性渐变的支持有限。
Modernizr does not add vendor prefixes. It only checks what a browser supports.
You can use this jQuery plugin.
https://github.com/codler/jQuery-Css3-Finalize it will automatically add vendor prefixes. But it has limited supported for linear-gradient.
我认为您正在寻找的是 http://prefixr.com/index.php
I think what you're looking for is http://prefixr.com/index.php