[英]resizing div width with browser resize
i recently asked this question on how to have a container div width set so i could avoid scrolling for folks with wide monitors. 我最近问了这个问题,关于如何设置容器的div宽度,这样我就可以避免滚动查看带有宽显示器的人。 I got a great answer basically to combine min-width with display: block ; 我基本上结合了min-width和display:block得到了一个很好的答案。
I now have one follow up. 我现在有一个后续行动。 The accepted answer works great if the browser up front is set to be wide but if at first its not wide and a user stretchs the window, the div container doesn't change or stretch. 如果将前面的浏览器设置为宽,但可以接受的答案非常有用,但是如果最初它不宽,并且用户拉伸窗口,则div容器不会更改或拉伸。
is there anyway i can take this one step further and reset the width of the div when the browser window itself resizes. 无论如何,在浏览器窗口本身调整大小时,我可以进一步执行此步骤并重置div的宽度。
you could use absolute positioning, 您可以使用绝对定位,
#panel {
position: absolute;
top: 50px;
left: 50px;
right: 50px;
bottom: 50px;
background: #eee;
border: 3px double #000;
overflow: auto;
}
<div id="panel"><p>I shrink and grow</p></div>
overflow:auto;
sets a scroll bar on the #panel
itself if the content requires it.. which may not be desired? 如果内容需要,可在#panel
上设置滚动条。
How about estimating the area of screen, your page should cover and writing the width in percentage? 估计屏幕面积如何,您的页面应覆盖并以百分比书写宽度?
For example, 例如,
#wrapper { width: 90%; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.