防止div在窗口大小上移动 [英] prevent div moving on window resize

查看:94
本文介绍了防止div在窗口大小上移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,里面有两个divlist_events和right_content。
当我调整窗口的大小时,right_content向下移动list_events,但我不想要!
我不希望这两个div既不能在窗口大小上移动也不能缩小..我怎么能达到这个目的?



这是代码

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

感谢
Luca

解决方案

首先添加一个父div / wrap,然后将这两个div放入它中。



像这样:

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

< / div>

然后您可以尝试

min如下所示:/ b>

  #wrap {
min()/宽度(px / ems / etc) -width:600px;

$ / code $ / pre
$ b $ p总的来说,无论你添加到最小宽度的大小,缩小到指定的大小。



一旦窗口缩小超过指定的大小,它就会像其他窗口一样运行。



这是我做这件事的方式。


I have a page with two divs "list_events" and "right_content" one next to each other. When I resize the window "right_content" moves down "list_events" but i dont want that! I dont want those two divs to move neither to scale down on window resizement..how can I achieve that?

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.

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:

#wrap{
min-width: 600px;
}

Overall, whatever size you add to the min-width itll scale the parent div down to the size specified.

once the window is sized down past your specified size, itll behave like any other window.

this is my way of doing it.

这篇关于防止div在窗口大小上移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆