【问题标题】:How to force IE to place two div boxes next to each other in it's browser window?如何强制 IE 在其浏览器窗口中将两个 div 框彼此相邻放置?
【发布时间】:2014-10-31 09:17:23
【问题描述】:

我已经为我的网站做了一个非常基本的布局。现在该网站在 Chrome、Mozila 和 Opera 中完美显示。

但唯一剩下的问题是 IE。由于我的浏览器窗口中有两个并排放置的框,因此 IE 只是将它们打断并将一个放在另一个下方,这是我绝对不想要的。

如何摆脱这个烦恼?

[注意:我还没有在网络服务器中发布我的网站。我只是在我的本地主机中运行它]

以下是我的完整代码:

.PHP:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>My site</title>
<link rel="stylesheet" href="style.css">

</head>



<body>

<div id="big_wrapper">

<header id="top_header">
<h1>My site</h1>


</header>

<nav id="top_menu">
<ul>
<li>Opening Hours</li>
<li>Registration</li>
</ul>

</nav>
<div id="new_div">
<section id="main_section">



<article>


<hgroup>
<header>
<h1>Title of article1</h1>
<h2>subTitle of article1</h2>

</header>
</hgroup>



<p>This is a best aricle1</p>

<footer>

<p> Written by...1</p>
</footer>

</article>


<article>


<hgroup>
<header>
<h1>Title of article2</h1>
<h2>subTitle of article2</h2>

</header>
</hgroup>



<p>This is a best aricle2</p>

<footer>

<p> Written by...2</p>
</footer>

</article>


</section>

<aside id="side_news">


<h4>News</h4>
Put your news

</aside>
</div>

<footer id="the_footer">


Put your footer

</footer>

</div>

</body>


</html>

.CSS:

*{
margin:0px;
padding:0px;
}
h1{

font:bold 20px Tahoma;
}
h2{

font:bold 14px Tahoma;
}
header,section,footer,aside,nav,article,hgroup{
display:block;

}
body{
width:100%;
display:-webkit-box;
display:-moz-box;
display:-ms-box;
box-pack:center;
-webkit-box-pack:center;
-moz-box-pack:center;
-webkit-box-pack:center;
-ms-box-pack:center;
/*
text-align:center;
*/
}


#big_wrapper{
max-width:1200px;
margin-top:20px;


display:-webkit-box;
display:-moz-box;
display:-ms-box;
box-orient:vertical;
-webkit-box-orient:vertical;
-moz-box-orient:vertical;
-ms-box-orient:vertical;
box-flex:1;
-webkit-box-flex:1;
-moz-box-flex:1;
-ms-box-flex:1;


}
#top_header{
background:yellow;
border:3px soild gray;
padding:20px;

}
#top_menu{
border:green;
background:gray;
color:white;
}
#top_menu li{
display:inline-block;
list-style:none;
padding:5px;
font:bold 14px Tahoma;

}

#new_div{
display:-webkit-box;
display:-moz-box;
display:-ms-box;
box-orient:horizontal;
-webkit-box-orient:horizontal;
-moz-box-orient:horizontal;
-ms-box-orient:horizontal;

}

#main_section{
border:1px solid blue;
box-flex: 1;
-webkit-box-flex: 1;
-moz-box-flex: 1;
-ms-box-flex: 1;

margin:20px;
padding:20px;


}

#side_news{
border:1px solid blue;
width:220px;

margin:20px 0px;
padding:30px;
background:#66CCCC;

}

#the_footer{

text-align:center;

padding:20px;
border-top:2px solid green;
}

【问题讨论】:

    标签: javascript php html css internet-explorer


    【解决方案1】:

    问题在于框的浮动和display 状态

    试试这个,它应该可以正常工作.. http://jsfiddle.net/4sdvk8gL/

    *{
    margin:0px;
    padding:0px;
    }
    h1{
    
    font:bold 20px Tahoma;
    }
    h2{
    
    font:bold 14px Tahoma;
    }
    header,section,footer,aside,nav,article,hgroup{
    display:block;
    
    }
    body{
    width:100%;
    display:-webkit-box;
    display:-moz-box;
    display:-ms-box;
    box-pack:center;
    -webkit-box-pack:center;
    -moz-box-pack:center;
    -webkit-box-pack:center;
    -ms-box-pack:center;
    /*
    text-align:center;
    */
    }
    
    
    #big_wrapper{
    max-width:1200px;
    margin-top:20px;
    
    
    display:-webkit-box;
    display:-moz-box;
    display:-ms-box;
    box-orient:vertical;
    -webkit-box-orient:vertical;
    -moz-box-orient:vertical;
    -ms-box-orient:vertical;
    box-flex:1;
    -webkit-box-flex:1;
    -moz-box-flex:1;
    -ms-box-flex:1;
    
    
    }
    #top_header{
    background:yellow;
    border:3px soild gray;
    padding:20px;
    
    }
    #top_menu{
    border:green;
    background:gray;
    color:white;
    }
    #top_menu li{
    display:inline-block;
    list-style:none;
    padding:5px;
    font:bold 14px Tahoma;f
    
    }
    
    #new_div{
    display:block;
    display:-moz-box;
    display:-ms-box;
    box-orient:horizontal;
    -webkit-box-orient:horizontal;
    -moz-box-orient:horizontal;
    -ms-box-orient:horizontal;
    
    }
    
    #main_section{
    border: 1px solid blue;
    -webkit-box-flex: 1;
    -moz-box-flex: 1;
    -ms-box-flex: 1;
    margin: 20px;
    padding: 20px;
    float: left;
    width: calc(75% - 82px);
    
    
    }
    
    #side_news{
    border: 1px solid blue;
    width: 220px;
    margin: 20px 0px;
    padding: 30px;
    background: #66CCCC;
    float: left;
    display: block;
    width: calc(25% - 62px);
    
    }
    
    #the_footer{
    
    text-align:center;
    
    padding:20px;
    border-top:2px solid green;
    }
    

    【讨论】:

      猜你喜欢
      • 2015-07-27
      • 2020-07-30
      • 2020-07-22
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多