CSS Max Height Property

后端 未结 6 1420
自闭症患者
自闭症患者 2020-12-05 04:30

Is there a good cross-browser way to set a max-height property of a DIV and when that DIV goes beyond the max-height, it turns int

6条回答
  •  盖世英雄少女心
    2020-12-05 04:53

    I found this solution from a post made in 2005 (Min-Height Fast hack). It's a hack but it's simple and pure CSS:

    selector {
      max-height:500px;
      height:auto !important;
      height:500px;
    }
    

    The example is for max-height, but it works for min-height, min-width and max-width. :)

    *Note: You must use absolute values, percentages don't work.

    All you need now is the "overflow:scroll;" to make this work with scroll bars

提交回复
热议问题