html - Scrollable container with columns and overflow-y: auto -


i want make scrollable container content laid out in columns. finding cannot use property column-count overflow-y: auto , fixed size on same element. content overflows horizontally, making more columns have specified in column-count.

html:

<ul>   <li>1</li>   <li>2</li>   <li>3</li>   <li>4</li>   <li>5</li>   <li>6</li>   <li>7</li>   <li>8</li>    </ul>  <ul class="with-columns">   <li>1</li>   <li>2</li>   <li>3</li>   <li>4</li>   <li>5</li>   <li>6</li>   <li>7</li>   <li>8</li>   </ul> 

css:

li {   list-style-type: none;   padding: 5px;   background: coral;   margin: 2px;   width: 80%;   display: inline-block;   height: 60px; }  li:nth-child(2n+3) {   height: 90px; /* simulate variable height content  items */ }  ul {   background: lightblue;   position: relative;   width: 300px;   height: 300px;   overflow-y: auto; }  ul.with-columns {   -moz-column-count: 2;   -webkit-column-count: 2;   -moz-column-gap: 0;   -webkit-column-gap: 0;   column-count: 2;   column-gap: 0; } 

how can make ul.with-columns vertically scrollable without wrapping in additional element?

jsbin: http://jsbin.com/gegawidayi/4/edit

i think might want instead set max-height instead of height on ul.

ul {     background: lightblue;     position: relative;     width: 300px;     max-height: 300px;     overflow-y: auto; } 

this should give you're looking for.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -