Search code examples
htmlcsscss-floatmove

How to move one element to the right of another using CSS?


I am trying to move one element next to another on my site.

enter image description here

Basically, I want the cart button to the right of quantity. float: right takes the button to the right place horizontally. But I also want to move them adjacent to each other.


Solution

  • .quantity is a block element (it takes the full row), so you can use float like this:

    .quantity {float: left;}
    

    Don't forget to clear:both; after if your floated elements start dropping out of their parent element (and they will unless there's a non-floated element that's higher than all of them).