One of the things that you can do is:
Set font-size: 0 for item_ul to remove the space characteristic of inline elements
Now reset the font-size to initial for the item_li
See demo below:
#content {
white-space: nowrap;
}
#item1 {
width: 500px;
}
#item2,
#item3 {
width: 400px;
}
#item_ul {
list-style-type: none;
white-space: nowrap;
overflow-x: auto;
font-size: 0;
}
.item_li {
border: solid 1px black;
display: inline-block;
font-size: initial;
}
<div id="content" style="overflow:scroll">
<ul id="item_ul">
<li id="item1" class="item_li">
a
</li>
<li id="item2" class="item_li">
b
</li>
<li id="item3" class="item_li">
c
</li>
</ul>
</div>
Another option is to use <!-- --> in the markup (and yes you are right write all the li in a single line) - see demo below:
#content {
white-space: nowrap;
}
#item1 {
width: 500px;
}
#item2,
#item3 {
width: 400px;
}
#item_ul {
list-style-type: none;
white-space: nowrap;
overflow-x: auto;
}
.item_li {
border: solid 1px black;
display: inline-block;
}
<div id="content" style="overflow:scroll">
<ul id="item_ul">
<li id="item1" class="item_li">
a
</li><!--
--><li id="item2" class="item_li">
b
</li><!--
--><li id="item3" class="item_li">
c
</li>
</ul>
</div>