Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 914
Chirag Avatar asked Feb 15 '23 10:02

Chirag


2 Answers

.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).

like image 128
Shomz Avatar answered Feb 17 '23 22:02

Shomz


You can set the container of the number choosing element to

float: left;

and the button to

display: inline; 

http://jsfiddle.net/v7ryN/

like image 34
ANortonsmith Avatar answered Feb 17 '23 22:02

ANortonsmith