My dilemma involves a horizontal list of items that expand the full width of their container and wrap onto the next line. However, I only want to show two lines of items initially, with a "show more" link to reveal additional rows in increments of two until all are displayed.
I have provided the following markup, but I'm unsure how to limit the display to just the first two rows. Any suggestions on achieving this? Keep in mind that the width of the containing element can change dynamically, so the two displayed rows should adapt accordingly.
.items {
overflow-y:hidden;
max-height:30px;
}
.item {
border-radius: 3px;
border-style: solid;
border-width: 1px;
cursor: pointer;
display: inline-block;
padding: 0;
text-align: center;
text-decoration: none!important;
vertical-align: middle;
margin-bottom: 10px;
margin-right: 10px;
}
.item-inner {
display: block;
position: relative;
overflow: hidden;
height: 29px;
border-radius: 2px;
}
.item-text {
background-color: transparent;
border: 0;
display: block;
font-size: 13px;
line-height: 29px;
margin: 0;
outline: 0;
padding: 0 10px 0 11px;
text-align: center;
white-space: nowrap;
}
<span class="items">
<span class="item"><span class="item-inner"><span class="item-text">Item 1</span></span></span>
<span class="item"><span class="item-inner"><span class="item-text">Item 2</span></span></span>
<span class="item"><span class="item-inner"><span class="item-text">Item 3</span></span></span>
<span class="item"><span class="item-inner"><span class="item-text">Item 4</span></span></span>
...
</span>