比浏览器更广泛的股利不滚动浏览器 [英] Div wider than browser without browser scrolling
问题描述
我的工作布局,其中主要内容的div将有一个具有970像素。这背后的div,我想与尺寸位置,像这样一个div 1200x600px(它将包含Flash对象):
I'm working on a layout where the main content div will have a with of 970px. Behind this div, I want a div with dimensions 1200x600px (it will contain a flash object) positioned like so:
width:1200px;
height:600px;
position:absolute;
left:50%;
margin-left:-600px;
当浏览器尺寸的宽度小于1200像素的问题是,它让水平滚动条。我可以解决这个问题是:
The problem is when the browser is sized to a width smaller than 1200px it get the horizontal scroll bar. I can fix that by:
body {overflow-x:hidden;}
但我确实希望它有水平滚动条时,它的宽度得到尺寸小于970像素。
But I DO want it to have the horizontal scroll bar when it get sized to less than 970px in width.
基本上,我试图让1200像素的div表现得更像一个CSS背景图像。任何想法?
Basically, I am trying to get the 1200px div to behave more like a css background image. Any ideas?
推荐答案
这工作没有JavaScript的:
This works without JavaScript:
<body style="margin:0">
<div style="position:absolute;width:100%;height:600px;overflow:hidden;min-width:970px;z-index:0;">
<div style="position:absolute;width:1200px;height:600px;left:50%;margin-left:-600px;">
--flash object--
</div>
</div>
<div style="position:absolute;width:100%;z-index:100;">
--main content--
</div>
</body>
更新:只好进行更改,以适应您的绝对定位的div(父div有需要绝对定位以及)
UPDATE:Had to make changes to accommodate your absolute div positioning (the parent div has to be absolutely positioned as well)
这篇关于比浏览器更广泛的股利不滚动浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!