Internet Explorer 8和边距

时间:2011-01-31 23:25:02

标签: html css internet-explorer

我有一些非常简单的HTML 这是为了制作如下布局。

要从用户栏中向下推动标签我正在使用
margin-top: 35px;
但是在Internet Explorer中,选项卡完全不对齐(选项卡的顶部是底部的位置)。

所以我需要将margin-top: -50px;用于Internet Explorer。

为什么会这样,如何在不使用特定样式表的情况下修复它

layout example http://webspirited.com/layout.png

<div id="pageHead">
  <div id="userBar">
    <span class="bold">Hi Matthew Hailwood | <a href="#">Logout</a>
  </div>
  <a href="http://localhost/buzz/" id="pageLogo"></a>  
  <div id="pageTabs" class="clearfix">
    <ul>
      <li><a href="http://localhost/buzzil/templates">Templates</a></li>
      <li><a href="http://localhost/buzzil/messaging">Messaging</a></li>
      <li><a href="http://localhost/buzzil/contacts">Contacts</a></li>
    </ul>
  </div>
</div>

css是

#pageHead {
    height: 100px;
}

#pageLogo {
    float: left;
    width: 149px;
    height: 77px;
    margin-top: 11px;
    background: transparent url('../images/logo.png') no-repeat;
}

#userBar {
    text-align: right;
    color: #fff;
    margin-top: 10px;
}

#userBar a:link,
#userBar a:visited,
#userBar a:active {
    font-weight: normal;
    color: #E0B343;
    text-decoration: none;
}

.clearfix:after {
    content: ".";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

.clearfix {
    display: inline-block;
}

html[xmlns] .clearfix {
    display: block;
}

* html .clearfix {
    height: 1%;
}

#pageTabs {
    float: right;
    margin-top: 35px;
}

#pageTabs ul {
    position: relative;
    width: 100%;
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid #000;
}

#pageTabs ul li {
    float: right;
    background: url(../images/tabsBg.png) no-repeat 0% 0%;
    border-left: 1px solid #000;
    margin-left: -1px;
}

#pageTabs ul li a:link,
#pageTabs ul li a:visited,
#pageTabs ul li a:active {
    color: #fff;
    background: url(../images/tabsBg.png) no-repeat 100% 0%;
    display: block;
    font-size: 14px;
    font-weight: bold;
    line-height: 42px;
    text-transform: uppercase;
    padding: 4px 32px;
    text-decoration: none;
}

#pageTabs ul li a:hover,
#pageTabs ul li a:focus {
    text-decoration: underline;
}

2 个答案:

答案 0 :(得分:3)

IE不喜欢负边距,它往往会有差异。请尝试使用position,以及leftrighttopbottom - 从个人经验来看,它更兼容。

您可能只需稍微调整即可将整页从边距转换为定位。

答案 1 :(得分:0)

尽量不要将html标记用于任何样式。请改用body标签。 另外,尝试将pageHead设置为相对定位,然后通过相对或绝对定位其他div,并使用top,bottom,left,right,如MT所述。

xD看起来我有点晚了。抱歉。 :3