How do I use max-height on <div> element?

 ̄綄美尐妖づ 提交于 2019-12-01 03:30:56

http://msdn.microsoft.com/en-us/library/ms530809(VS.85).aspx

says that max-height doesn't work with tables. try removing the table that is inside your div.

IE has supported max-height since IE7 — but only in Standards (AKA Strict) mode.

Make sure you have a Doctype that triggers standards mode as the first thing in your document. (Quirks mode can screw up a lot of things, so never write a document without a Standards mode triggering Doctype unless you have a very very good reason to do so).

Try setting just the height, and overflow to 'scroll'. Visually, there may not be a difference between the outter-box being full-height, and it not being full-height. If that is the case, I would simply refrain from using max-height in place of height.

Could you show us a bit more of your code, or perhaps an online demonstration? I'd be interested in seeing some of the css, and the doctype.

captainspi

In addition to max-wdith, you may use the following expression to make sure it is cross browser compatible:

width: expression(this.width > 400 ? "400px" : true);
height: expression(this.height > 400 ? "400px" : true)

reference: http://www.fastechws.com/tricks/web/image-max-width-height.php

What version of IE7 are you using? Max-height support wasn't added until beta 2.

The scrollbar shows up in the Compatibility View (the IE7 engine) in IE8.

Are you sure you aren't using IE6?

I just copy and pasted your code, and then dropped in a php loop to create 200 rows or just 2 and it behaves the same in IE 7, Safari, and Firefox.

You probably aren't declaring a doctype, that creates the problem you're describing in my test.

Or in your real code you haven't properly defined overflow:auto. Your issue is exactly what would happen if that was the case.

It's defined here in the question, but maybe not your code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!