【问题标题】:How to access object.style.filter for firefox browser?如何访问 Firefox 浏览器的 object.style.filter?
【发布时间】:2011-08-25 04:12:53
【问题描述】:

我正在使用object.style.filter='Gray'object.style.filter='fliph'object.style.filter='flipv'object.style.filter='invert',这在 IE 中有效,但在 Firefox 中无效。你能帮忙吗?

【问题讨论】:

    标签: javascript html css firefox


    【解决方案1】:

    Firefox 中的.style.filter 公开了SVG 定义的filter CSS 属性。此属性的有效值不包括 'Gray'。见http://www.w3.org/TR/SVG11/filters.html#FilterPropertyhttps://developer.mozilla.org/en/applying_svg_effects_to_html_content#Example.3a.c2.a0Filtering

    【讨论】:

      【解决方案2】:

      过滤器是 IE 特定的。 CSS 可以在 IE 和 FF 中设置颜色:

      object.style.backgroundColor = 'gray'
      

      如果您的目标是为整个 div 着色,最好的办法是创建一个覆盖第一个 div 并且部分透明的新 div。

      【讨论】:

      • @Zake 它在 Firefox 中不起作用,但它也适用于背景。 div里面有任何图像,那个东西我也想改变颜色,比如阴影。
      • 啊,那么最好的办法就是在第一个前面使用一个部分不透明的div,这里是一个例子:stackoverflow.com/questions/4416007/…
      猜你喜欢
      • 2020-12-27
      • 1970-01-01
      • 2017-03-04
      • 2021-06-01
      • 1970-01-01
      • 2022-06-11
      • 2011-09-22
      • 2018-09-17
      • 2022-01-18
      相关资源
      最近更新 更多