Reputation: 18560
I have three DIVs:
<div style="float:left;" id="a"> a </div>
<div style="float:left;" id="b"> b </div>
<div style="float:left;" id="c"> c </div>
I want all DIVs in same line but in some browsers, last DIV come down because of size of content in DIVs.
How to restrict them to be in same line even their is more content in DIVs. In this case horizontal scrollbar will be used to see all content.
Thanks
Upvotes: 1
Views: 955
Reputation: 639
You need to wrap your divs in a parent div and set 'white-space: nowrap' on it. Also, set 'display:inline-block' for you divs to get the desired effect.
Try something like this,
.parent {
white-space: nowrap;
}
.child {
width: 200px;
height: 200px;
display:inline-block;
}
<div class="parent">
<div class="child" id="a"> a </div>
<div class="child" id="b"> b </div>
<div class="child" id="c"> c </div>
</div>
Upvotes: 5
Reputation: 11354
Try this:
<div style="display: inline-block;">a</div>
<div style="display: inline-block;">b</div>
<div style="display: inline-block;">c</div>
Upvotes: 1