How to make two div align side by side?

css, html

Solution

You need to add `display: inline-block` on the elements you wish to align side by side, as `div` elements have a default style of `display: block`, meaning they will stack vertically instead of horizontally (not the behaviour you want).

From the looks of it; the shopping cart box is too wide to fit side by side in the content container as well. Make the div with the id `centre` wider (possibly to 1000px instead of 960px), and coupled with the addition of changing the `display` property, that should do it.

In terms of the code you need to write directly in order to get this to change, do the following:

#centre {
    width: 1000px;
}

.cartbox {
    display: inline-block;
}

EDIT: I modified these changes to your website locally and it appears to have worked.

Problem

I have been trying to make two divs float side by side or basically the shopping cart and the items (namely jcart and cartbox) but cant seem to get it. Here is the demo: link i tried change `float:right;` on the cartbox css but that would only move the shopping cart to the right and if I remove the float on the cartbox css.. The cart and the items align side by side but for some reason cart appears to be really small and the "add to cart" button doesn't appear to click. Any help will be appreciated! HTML: ``` <form method="post" action="" class="jcart"> <fieldset> // item details here </fieldset> </form> <div class='cartbox'> <div id="jcart"><?php $jcart->display_cart();?></div> <div id='jcart-loader'><img src='img/ajax-loader.gif' alt=''></div> </div> ``` CSS: ``` #jcart { position:relative; font-size:1.15em; top:0; margin:0 0 .75em; } .jcart { width:135px; margin:0 20px 20px 0; padding-top:20px; border:solid 2px #E5E5E5; float:left; background:#F0F0F0; text-align:center; } .cartbox { float:left; position:relative; top:0; width:500px; margin:0; padding:0; } ```

Original source

Related problems