LoginSignup
13
11

More than 5 years have passed since last update.

IE8のmax-heightとoverflowのバグ

Last updated at Posted at 2013-07-04

地味にハマったのでメモ。

max-heightを設定してoverflowをscrollやautoにすると、IE8ではmax-heightが普通のheightのように設定されてしまう。
回避策としてdivを入れ子にしてoverflowを設定後、その中に再度divを設定してmax-heightの設定をするときちんと表示される。

全くもって意味の分からない話だが、どうやらIE8のバグらしい。
このためにわざわざCSSを別々に分けて入れ子にするという手間のかかりよう…。

ダメな例

CSS
.AAA { max-height:300px; overflow:scroll;}
HTML
<div class="AAA">
     <table>
          <tr>
             <td>contents2</td>
             <td>contents2</td>
          </tr>
            ~
          <tr>
             <td>contents3</td>
             <td>contents4</td>
          </tr>
     </table>
</div>


いい例

CSS
.AAA { overflow:scroll;}
.BBB { max-height:300px;}
HTML
<div class="AAA">
  <div class="BBB">
     <table>
          <tr>
             <td>contents1</td>
             <td>contents2</td>
          </tr>
            ~
          <tr>
             <td>contents3</td>
             <td>contents4</td>
          </tr>
     </table>
  </div>
</div>
13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11