停止调整div容器的大小 [英] Stop div container from resizing

查看:83
本文介绍了停止调整div容器的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html页面中有两列,一列向右浮动,另一列向左浮动。
我将两个容器的高度都设置为100%,两个容器的宽度都设置为50%。我希望这两个容器适合进入窗口。当用户水平调整窗口大小时,我不希望内容调整大小。我如何实现呢?

I have two columns in an html page, one is floated right and the other is floated left. I have set the height of both containers to 100% and the width of both containers to 50%. I want the two containers to fit the entre window. When the user re-sizes the window horizontally I don't want the content to resize. How can i achieve this?

谢谢

推荐答案

有很多实现这一目标的方法。首先,最简单的方法是将css值设置为min-width!因此,如果要调整大小但要停止在960px,例如:

There is many way to achieve that. First of all, the easiest would be to put the css value min-width! So if you want it to resize but to stop at 960px (for example) you just have to do :

    myCoolDiv{
         width: 100%;
         height: 50%;
         min-width: 960px;
   }

这将为您带来最佳效果。否则,如果您根本不想调整内容的大小,并且选择器的宽度等于初始屏幕的100%,则可以使用jQuery:

That would give you the best result. Else, if you dont want content to resize at all, and the selector to have a width equal to 100% of the initial screen, I would use jQuery that way:

    $(document).ready(function() {
       //Call a variable to know the width of the window
       var screenWidth = $(window).width();
       $('myCoolDiv').css('width', screenWidth + 'px');
    });

希望对您有所帮助!告诉我我的答案是否还不清楚,或者您不了解其中的一部分!

Hope it helped! Tell me if my answer is not clear enough or if you don't understand a part of it!

干杯!

这篇关于停止调整div容器的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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