【问题标题】:conditional formatting: I want to use javascript for rounded corner but only if it's in IE条件格式:我想将 javascript 用于圆角,但前提是它在 IE 中
【发布时间】:2012-07-15 22:49:38
【问题描述】:

我使用 -moz-border-radius 和 -webkit-border-radius 来制作圆角。然而,我们知道 IE 7 不支持这一点。我想做的是基本上使用Firefox和Safari的标准,但是对于IE我想使用javascript。通过使用这个http://www.editsite.net/blog/rounded_corners.html

我的问题是如何设置条件以便每个浏览器都知道呈现页面的方式?

【问题讨论】:

  • 仅供参考,-moz-border-radius-webkit-border-radius 不是标准的。以 - 开头的 CSS 属性是特定于浏览器的。 border-radius 是在 CSS3 中引入的,但 CSS3 支持还没有真正普及。

标签: css internet-explorer rounded-corners


【解决方案1】:

使用conditional comments 包含<script> 仅用于MSIE。

【讨论】:

    【解决方案2】:

    只需在你的 CSS 中保留 -moz-border-radius 和 -webkit-border-radius 规则,IE 将完全忽略它们。您可以使用conditional comments 为 IE 放置 javascript,如下所示:

    <!--[if IE]>
        <script type="text/javascript">
            Rounded('rounded', 6, 6);
        </script>
    <![endif]-->
    

    除 IE 之外的所有浏览器都会完全忽略这一点。如果您只想对特定版本的 IE 使用此功能,请改用此功能:

    <!--[if IE 7]>
        <script type="text/javascript">
            Rounded('rounded', 6, 6);
        </script>
    <![endif]-->
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多