CSS max-height不工作 [英] CSS max-height not working

查看:102
本文介绍了CSS max-height不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的问题,我需要一个div来展开以适应其内容,除非高度达到一定的大小,当我想要div垂直滚动。作为一个测试,我创建了一个页面包含:

I have a very simply problem where I need a div to expand to fit its contents unless the height reaches a certain size, when I want the div to scroll vertically instead. As a test, I created a page containing:

<div style="width:300px;max-height:25px;background-color:green;overflow:auto;">
    1<br />
    2<br />
    3<br />
    4<br />
    5
</div>


$ b <我做错了什么?

Unfortunately, the max-height doesn't seem to work. What am I doing wrong?

我使用的是IE7。

推荐答案

问题是你的浏览器。也许你可以将这个div包装在固定高度为25px的另一个div中。当然,这不会和max-height完全一样。

The problem is your browser. Maybe you could wrap this div in another div that has the fixed height of 25px. Of course this wouldn't be exactly the same as max-height.

有关解决方案的文章

修改根据Microsoft ,它应该在IE7 +中工作。

According to Microsoft it should work in IE7+.

是否设置了适当的doctype?如果不是IE7使用旧布局引擎。您应该使用HTML 4或XHTML。

Have you set an appropriate doctype? If not IE7 uses an old layout engine. You should use HTML 4 or XHTML.

这篇关于CSS max-height不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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