显示位置:相对兼容性问题

时间:2013-04-04 07:14:19

标签: css internet-explorer positioning

显示=“位置:相对;”是IE中的杂耍(浏览器模式:IE7 / 8/9 - 文档模式:怪癖)但是如果我将文档模式从Quirks更改为IE7 / 8甚至9,它的工作正常。如何设置CSS这个问题?请参阅以下示例代码:

CSS

.aFlyOut{
    padding: 10px;
    bottom: 0px;
    border: 1px solid #a6adb3;
    background-color: #FFFFFF;
    position: relative;
    z-index: 9999;  
}

.aFlyoutCollapse
{
    background-image:  url("/vtpOnline/images/settings.png");
    background-repeat: no-repeat;
    background-position: 100% 50%;  
    cursor:pointer;
    width:40px;
    height: 20px;
    text-indent: 21px;
    color: #FFFFFF;
}   

.aFlyoutExpand
{
    background-image:  url("/vtpOnline/images/settings.png");
    background-repeat: no-repeat;
    background-position: 100% 50%;
    cursor:pointer;
    width:40px;
    height: 20px;
    text-indent: 21px;
    color: #FFFFFF;
}

.aFlyoutButton{
    height: 12px;
    float: right;
    width: 38px;
    cursor: hand;
    padding-right: 4px;
}
.aFlyout{
    float: right;
    background-color: #FFFFFF;
    border:1px solid #a5acb2;
    right: 6px;
    #right: 8px;
    padding: 0px;

}
.aFlyoutHeader{
    padding: 4px 6px 3px 0;
    background: url("/vtpOnline/images/actionFlyoutHeaderIcon.gif") #090999 no-repeat;
    color: #FFFFFF;
    text-indent: 23px;
    font-size: 11px;
    font-weight: bold;
}
.aFlyoutLinkWrapper{
    padding:5px;
}
.aFlyoutLinkWrapper a{
    padding: 5px;
    color: #010356;
    font-size: 11px;
    display: block;
    text-decoration: none;
}
.aFlyoutLinkWrapper a:hover{
    color: #0060ff;
    background-color: #f2f2f2;
}
.aFlyoutRefreshLink{
    background: url("/vtpOnline/images/addNote.png") no-repeat 0 50%;
    text-indent: 12px;
    #text-indent: 10px;
}

HTML

<div class="aFlyoutButton" id="aFlyoutLink"> 
  <!-- Action Flyout Action Button -->
  <div class="aFlyoutExpand" title="Actions" id="aFlyoutButton" onMouseOver="aFlyoutExpand()" onMouseOut="aFlyoutExpandCollapse()" onClick="aFlyoutExpandCollapse()"> </div>
  <div id="aFlyout" class="aFlyout" style="display: block;" onMouseOver="aFlyoutExpand()" onMouseOut="aFlyoutExpandCollapse()"> 
    <!-- Action Flyout Action Header -->
    <div class="aFlyoutHeader" style="color: #FFFFFF;font-size: 11px !important;"> Actions </div>
    <!-- Action Flyout Links Panel -->
    <div class="aFlyoutLinkWrapper" style="width: 100px;"> <a class="aFlyoutRefreshLink" href="#" id="j_id_jsp_2094016106_1:REFRESHNOTESCREENACTION" name="j_id_jsp_2094016106_1:REFRESHNOTESCREENACTION" onClick="aFlyoutExpandCollapse();;A4J.AJAX.Submit('j_id_jsp_2094016106_0','j_id_jsp_2094016106_1',event,{'oncomplete':function(request,event,data){Richfaces.showModalPanel('AddNoteModalPanel');setValues();return false;},'similarityGroupingId':'j_id_jsp_2094016106_1:REFRESHNOTESCREENACTION','parameters':{'j_id_jsp_2094016106_1:REFRESHNOTESCREENACTION':'j_id_jsp_2094016106_1:REFRESHNOTESCREENACTION'} ,'actionUrl':'/vtpOnline/faces/order/edit/default.jsf'} );return false;">Notes</a> </div>
  </div>
</div>

当鼠标悬停时显示:

enter image description here

但是,它应该是:

enter image description here

2 个答案:

答案 0 :(得分:0)

文档模式怪癖意味着您基本上运行的是IE6之前的渲染引擎。解决此问题的一个好方法是在HTML文档的顶部添加doctype。这将默认将浏览器置于标准模式,并允许您的位置:相对;按预期工作。

最简单的doctype是HTML5:

<!DOCTYPE html>

将其放在HTML的第1行。没有办法通过CSS强制标准模式。

答案 1 :(得分:0)

谢谢大家,它已经得到解决;请参阅以下代码参考。我已将位置从相对位置改为绝对位置并设置顶部和顶部高度来固定定位。

.aFlyOut{
   position: absolute;
   top: 28px;
   height: 70px;
}