【问题标题】:Internet Explorer treating div width as 100%?Internet Explorer 将 div 宽度视为 100%?
【发布时间】:2012-03-04 00:25:47
【问题描述】:

图像(徽标)的宽度似乎是 100%,因为它正在向下推(header_box)下面的 div。所有其他浏览器 header_boxes 出现在徽标的右侧,但 Internet Explorer(当然)正在做不同的事情。

html

<body>
    <div id="header">
        <img id="logo" src="images/logo.png" alt="Logo" />
        <div class="header_box">
            <img id="profile" src="images/questionmark.png" alt="Profile Image" />
            <span id="profile_name">Sample</span><br />
            <ul id="profile_settings">
                <li>Profile</li>
                <li>Settings</li>
            </ul>
        </div>
        <div class="header_box">
            <img id="notifications" src="images/notifications.png" alt="Notifications" />
        </div>
        <div class="clear"></div>
    </div>

CSS

#header {
background:#3A3A3A;
color:white;
border-bottom:5px #771439 solid;
-moz-box-shadow: 0 1px 5px 3px #888;
-webkit-box-shadow: 0 1px 5px 3px#888;
box-shadow: 0 1px 5px 3px #888;
}

#logo {
height:82px;
display:inline;
}

.header_box {
display:inline-block;
float:right;
background:#262626;
padding:5px;
margin:16px 15px 12px 0;
border-radius: 5px; 
-moz-border-radius: 5px; 
-webkit-border-radius: 5px; 
border: 1px #474747 solid;
text-align:left;
font-size:11px;
min-height:40px;
}

如果您需要更多信息,请告诉我。我不确定如何描述这个问题。

【问题讨论】:

    标签: html css internet-explorer cross-browser


    【解决方案1】:

    这是旧版本 IE 中的常见问题。您应该能够将所有内容包含在一个带有高度的 div 中,并在您的徽标 css 中包含float:leftHere 是一个 jsfiddle 来尝试一下。

    HTML

    <div style="height"82px;">
        <img id="logo" src="images/logo.png" alt="Logo" />
        <div class="header_box">
            <img id="profile" src="images/questionmark.png" alt="Profile Image" />
            <span id="profile_name">Sample</span><br />
            <ul id="profile_settings">
                <li>Profile</li>
                <li>Settings</li>
            </ul>
        </div>
        <div class="header_box">
            <img id="notifications" src="images/notifications.png" alt="Notifications" />
        </div>
    </div>
    

    CSS

    #logo {
    float:left;
    height:82px;
    display:inline;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-08
      • 2012-01-14
      • 2013-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多