html - Resize position absolute element width to content with CSS -
i'm trying put elements in horizontal row can scroll through them, have made inner , outer container. outer container has fixed width , inner container should have width determined it's content can larger outer div.
html
<div id="outer"> <div id="inner"> <ul> <li class="item"></li> <li class="item"></li> <li class="item"></li> <li class="item"></li> <li class="item"></li> </ul> </div> </div>
css
#outer{ width:250px; position: relative; /* required make overflow hidden work */ overflow:hidden; /* commented demonstrate issue */ background-color: lightgreen; height: 80px; } #inner { position: absolute; width: 1000px; /* <- needs scale content */ } ul { margin: 0; padding: 0; } .item:first-child{ margin-left:0; } .item { width: 100px; height: 80px; background-color: lightblue; margin-left: 10px; display:inline-block; }
i'm trying solve issue using css alone i've been unsuccesful far. for issue, browser compatibility non-issue.
what have
what want
Comments
Post a Comment