简体   繁体   English

防止div移动窗口调整大小

[英]prevent div moving on window resize

I have a page with two divs "list_events" and "right_content" one next to each other. 我有一个页面,其中两个div“list_events”和“right_content”彼此相邻。 When I resize the window "right_content" moves down "list_events" but i dont want that! 当我调整窗口大小时“right_content”向下移动“list_events”,但我不想要那样! I dont want those two divs to move neither to scale down on window resizement..how can I achieve that? 我不希望这两个div既不移动也不缩小窗口调整大小。我可以实现吗?

this is the code 这是代码

.list_events{margin-left:1em;float:left;}
.right_content{float:left;margin-left:1em;}

thanks Luca 谢谢卢卡

first add a parent div/wrap and put those two divs of yours into it. 首先添加一个父div / wrap并将你的两个div放入其中。

like so: 像这样:

<div id="wrap">
   <div id="list_events"></div>
    <div id="right_content"></div>

</div>

then you can try the 然后你可以试试

min-width(px/ems/ etc) on the parent/wrapper div like so: 父/包装器div上的min-width(px / ems / etc)如下:

#wrap{
min-width: 600px;
}

Overall, whatever size you add to the min-width itll scale the parent div down to the size specified. 总的来说,无论你添加到min-width的大小,它都会将父div缩小到指定的大小。

once the window is sized down past your specified size, itll behave like any other window. 一旦窗口大小超过指定的大小,它的行为就像任何其他窗口一样。

this is my way of doing it. 这是我做这件事的方式。

您可以将此div放在具有固定宽度/高度的父div中,或者您可以确定每两个div的百分比宽度/高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM