今天遇到了一个奇怪的问题。我一直在使用一个浮动菜单,它适用于我到目前为止测试过的所有东西(还没有升级到旧的IE版本...),除了firefox。页面在第一次加载时会正确呈现,但如果调整窗口大小,受浮动元素影响的具有确定性布局的元素(即内联元素、带有overflow:hidden的div等)将无法更新。
有谁有(最好是免费的javascript )的变通方法?
HTML:
<div id="leftBar">
<a>test1</a>
<a>test2</a>
</div>
<div id="bodyContent">
<div>
<div id="contenta">
Hello world!
</div>
</div>
<div>
<p>Paragraph test</p>
</div>
<div style="clear:both">
Enclosing div.
</div>
</div>CSS:
#leftBar {
float:left;
width:50px;
background:red;
height:75px;
}
#bodyContent {
margin:0 auto;
width:500px;
background:green;
}
#bodyContent > div {
overflow: hidden;
}
#contenta {
width:100%;
height:50px;
background:blue;
}jsfiddle here。
发布于 2013-05-22 08:55:29
我不确定这是否是您想要实现的目标,但我个人会使用容器来存储元素。
#container {
width: 550px;
}
#leftBar {
float:left;
width:50px;
background:red;
height:75px;
}
#bodyContent {
margin:0 auto;
width:500px;
background:green;
overflow: hidden;
}
#contenta {
width:100%;
height:50px;
background:blue;
}然后将您的内容包装在容器中。
https://stackoverflow.com/questions/16681745
复制相似问题