简体   繁体   English

高度:自动; 不适用于Firefox

[英]height: auto; doesn't work with firefox

I have Div Container with css class: 我有CSS类的Div容器:

    .content4
   {
    height: 1400px;
    width: 920px;
    border: 1px solid #CCCCCC;
    background-color: #FFFFFF;
    padding-bottom: 25px;
    padding-top: 25px;
    background-image: url(../images2/bg.gif);
   }

and i need to make it auto height for its content 我需要为其内容设置自动高度

its working properly in IE but doesn't work in firefox. 它在IE中正常工作,但在Firefox中不工作。

any help please? 有什么帮助吗?

Use something like that: 使用类似的东西:

.test
{
     min-height: 300px;
     height: auto !important;  /* for other browsers */
     height: 300px;  /* for IE */
}

If I understood the case correctly, your style is working like it should (in FF, of course :)) If you specify the particular height, the div should not change its height when its content wants more. 如果我正确地理解了这种情况,则您的样式将按其应有的方式工作(当然,在FF中:))如果指定了特定的高度,则当其内容需要更多时,div不应更改其高度。 What you observe in IE is that it's actually treating a "height" as a "min-height". 您在IE中观察到的是,它实际上将“高度”视为“最小高度”。 The solution here is to specify min-height for browsers, and height for IE :) 这里的解决方案是为浏览器指定min-height,为IE指定高度:)

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

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