CSS 3 PIE:悬停不起作用

时间:2012-11-27 23:31:48

标签: css3 css3pie

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>

3 个答案:

答案 0 :(得分:3)

您必须设置范围以监视悬停元素的行为更改(在您的情况下,&#39;工具提示&#39;元素)。设置范围以观看工具提示&#39;通过添加:

来改变行为
.tooltip span {
    -pie-watch-ancestors: 1;
}

&#39; 1&#39;表示与圆形边界元素相关的祖先级别。

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

答案 1 :(得分:0)

尝试将行为应用于没有: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>

答案 2 :(得分:0)

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

尝试将行为:url(PIE.htc); 放在.tooltip {}中。它为我工作。