Reputation: 1918
I would like to have two tags side-by-side as if being two columns.
So far I have
<div id="wrapper">
<div id="1">text here</div>
<div id="2">text here</div>
<div style="clear:both"></div>
</div>
What I'm having difficulty with is the CSS for the divs. Any help?
Upvotes: 2
Views: 40846
Reputation: 719
#1, #2 {
display: inline-block;
}
Given that both #1 and #2 divs have a total width of not greater than the parent div.
If you use float, you will end up changing them to inline-block once you have to position a child div into absolute.
Upvotes: 0
Reputation: 507
May be you can try:
div#wrapper {
display: table;
}
div#wrapper div {
display: table-cell;
padding: 5px;
}
or this one:
div#wrapper div {
display: inline-block;
}
Upvotes: 3
Reputation: 28753
You could use float:left
in conjunction with overflow-x:hidden;
like so:
#1 {
float:left
}
#2 {
overflow-x:hidden;
}
Upvotes: 1
Reputation: 2398
As a start:
<div id="wrapper">
<div style="float:left;" id="1">text here</div>
<div style="float:left;" id="2">text here</div>
<div style="clear:both"></div>
</div>
Upvotes: 2
Reputation: 72991
Check out the float
property.
Quick example:
#1, #2 {
float: left;
width: 49%;
}
Check out this beginner tutorial on CSS Floats.
Upvotes: 6