我试图“侧翼”一个中心的div,一些设计元素绝对位于主div宽度之外.由于右侧的元素,而不是左边的元素(IE6 / 7/8,Chrome,Firefox),我正在滚动条.如何摆脱这个水平滚动条?
<html> <head> <style type="text/css"> html,body { height: 100%; width: 100%; margin: 0; } body { text-align: center; } .wrapper { margin: 0 auto; position: relative; width: 960px; z-index: 0; } .main { background: #900; height: 700px; } .right,.left { position: absolute; height: 100px; width: 100px; } .right { background: #090; top: 0px; left: 960px; z-index: 1; } .left { background: #009; top: 0px; left: -100px; z-index: 1; } </style> </head> <body> <div class="wrapper"> <div class="main"></div> <div class="left"></div> <div class="right"></div> </div> </body> </html>
@R_403_323@
这可以在IE6-9,FF3.6,Safari 5和Chrome 5中运行.似乎没有关系我扔给我的是什么类型的文件(没有,xhtml 1过渡,html5).希望这有帮助,那是一个有趣的问题.
<!DOCTYPE html> <html> <head> <style type="text/css"> html,body { margin: 0; padding: 0; text-align: center; } body { overflow: auto; } #container { min-width: 960px; zoom: 1; /*For ie6*/ position: relative; /*For ie6/7*/ overflow: hidden; margin: 0 auto; } #main { background: #cea; width: 960px; margin: 0 auto; height: 700px; position: relative; top: 0; } #right,#left { position: absolute; height: 100px; width: 100px; top: 0; z-index: 100; } #right { background: #797; right: -100px; } #left { background: #590; left: -100px; } </style> </head> <body> <div id="container"> <div id="main"> <div id="left">left</div> <div id="right">right</div> </div> </div> </body> </html>