【问题标题】:CSS 3 PIE :hover not workingCSS 3 PIE:悬停不工作
【发布时间】:2012-11-27 23:31:48
【问题描述】:

IE 不显示圆角。如果我取出:hover,它会起作用。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Untitled Document</title>
        <style type="text/css">
            .tooltip {
                position:absolute;
                text-decoration: none;
                display:inline-block;
            }
            .tooltip span {
                margin-left:-999em;             
            }
            .tooltip:hover span {
                background-color: black;
                border-radius: 5px;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
                color: #fff;
                display: inline-block;
                position: relative;
                left: 30px;
                padding: 10px;
                top:0px;
                z-index:1;
                behavior:url(PIE.htc);
                margin-left:0;
            }
        </style>
    </head>
    <body>
        <label>This is a label
            <a href="#" class="tooltip">
                <img src="img/help.jpg" style="border:1px solid black;width:15px;height:15px;position:absolute;left:5px;top:5px;"/>
                <span>This is a test</span>
            </a>
        </label>
    </body>
</html>

【问题讨论】:

    标签: css css3pie


    【解决方案1】:

    您必须设置跨度以观察悬停元素(在您的情况下为“工具提示”元素)的行为变化。通过添加以下内容来设置跨度以观察“工具提示”行为变化:

    .tooltip span {
        -pie-watch-ancestors: 1;
    }
    

    '1' 表示与圆角边框元素相关的祖先级别。

    更多信息在这里: http://css3pie.com/documentation/supported-css3-features/#pie-watch-ancestors

    【讨论】:

      【解决方案2】:

      尝试将行为应用于不带 :hover 伪类的元素:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <title>Untitled Document</title>
              <style type="text/css">
                  .tooltip {
                      position:absolute;
                      text-decoration: none;
                      display:inline-block;
                  }
                  .tooltip span {
                      margin-left:-999em;
                      behavior:url(PIE.htc);          
                  }
                  .tooltip:hover span {
                      background-color: black;
                      border-radius: 5px;
                      -moz-border-radius: 5px;
                      -webkit-border-radius: 5px;
                      color: #fff;
                      display: inline-block;
                      position: relative;
                      left: 30px;
                      padding: 10px;
                      top:0px;
                      z-index:1;
                      margin-left:0;
                  }
              </style>
          </head>
          <body>
              <label>This is a label
                  <a href="#" class="tooltip">
                      <img src="img/help.jpg" style="border:1px solid black;width:15px;height:15px;position:absolute;left:5px;top:5px;"/>
                      <span>This is a test</span>
                  </a>
              </label>
          </body>
      </html>
      

      您不应该隐藏具有负边距的元素:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <title>Untitled Document</title>
              <style type="text/css">
                  .tooltip {
                      position:absolute;
                      text-decoration: none;
                      display:inline-block;
                  }
                  .tooltip span {
                      left: 30px;
                      top:0px;
                      background-color: black;
                      color: #fff;
                      padding: 10px;
                      display: none;
                      border-radius: 5px;
                      -moz-border-radius: 5px;
                      -webkit-border-radius: 5px;
                      behavior:url(PIE.htc);     
                      z-index:1;
                      position: relative;
                  }
                  .tooltip:hover span {
                      display: inline-block;
                  }
              </style>
          </head>
          <body>
              <label>This is a label
                  <a href="#" class="tooltip">
                      <img src="img/help.jpg" style="border:1px solid black;width:15px;height:15px;position:absolute;left:5px;top:5px;"/>
                      <span>This is a test</span>
                  </a>
              </label>
          </body>
      </html>
      

      【讨论】:

        【解决方案3】:

        是的,您可以这样做,但您必须将行为声明放在不包含 :hover 选择器的样式规则中。您可以将其余样式保留在 :hover 块中。 关注这个IE at hover problem

        尝试将您的 behavior:url(PIE.htc); 放入 .tooltip{}。它对我有用。

        【讨论】:

          猜你喜欢
          • 2023-03-03
          • 2023-04-03
          • 1970-01-01
          • 2016-04-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-04-01
          • 2013-04-13
          相关资源
          最近更新 更多