I've never had a problem with aligning divs side by side but for some reason no matter what I do it just doesn't work. I tried a few answers from stackoverflow but they didn't work either. I've run out of ideas.
What I have are 2 divs. 1 div is "content" - it has all main info displayed in a table. Second div is "sidebar" - it has just some extra rubbish like images, twitter feed etc.
This is my CSS
#content {
width: 580px;
height:auto;
}
#sidebar {
width: 270px;
height:auto;
float:right;
}
I've tried to play with positioning, margins, containing those 2 divs in another - wrapper - one but it either doesn't work or creates another problem. Funny enough I am re-writing my old website and even if I copy the old attributes it still doesn't work. Anyone has any idea?
EVERYONE IS ALLOWED TO LAUGHT! LOL
SOLUTION: Delete div #clear which I totally forgot about! What a muppet. :-P Now I feel stupid. :-P
To display multiple div tags in the same line, we can use the float property in CSS styles. The float property takes left, right,none(default value) and inherit as values. The value left indicates the div tag will be made to float on the left and right to float the div tag to the right.
Simply put, if you have a div, and the elements inside are set to “display:inline-block” then you can just use “text-align:center” to center them inside.
To align two <div> elements vertically in Bootstrap 3, you can try using the CSS Flexible Box Layout. In the example below, we display the needed row as a flex container box with the CSS display property and then, align the flex-items (columns) vertically with the align-items property.
#content {
background:#eee;
width: 300px;
height:auto;
float: left;
}
#sidebar {
background:#c00;
width: 200px;
height:auto;
float:left;
}
<div id="content">Content</div>
<div id="sidebar">Sidebar</div>
To answer in a proper way, I need to see more than just two CSS id's, like the HTML page and the CSS file, but I did this:
JSFiddle
And maybe could help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With