Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to move a particular div to right

Tags:

css

I want to move a particular div more to the right side so that the div in the left gets some more space to display the contents in it.

I tried few things in CSS, but I know I am doing something wrong.

In CSS, I have...

login-box {     width: 200px;     margin-left: 50px; }  
like image 359
Bala Avatar asked Oct 03 '12 14:10

Bala


People also ask

How do I move something to the right of a div?

You can use float on that particular div, e.g. If all else fails give the div on the right position:absolute and then move it as right as you want it to be.

How do you position a div to the right in a div?

The best method for positioning #div1 depends on whether you want it to affect the position of the other chid divs. If so, apply float: right; to #div1 . If not, position: absolute; is the way to go; you may want to add padding to the right of #divContainer so that #div1 doesn't sit on top of the other child divs.

How do I move an element to the right side in CSS?

If position: absolute; or position: fixed; - the right property sets the right edge of an element to a unit to the right of the right edge of its nearest positioned ancestor. If position: relative; - the right property sets the right edge of an element to a unit to the left/right of its normal position.


1 Answers

You can use float on that particular div, e.g.

<div style="float:right;"> 

Float the div you want more space to have to the left as well:

<div style="float:left;"> 

If all else fails give the div on the right position:absolute and then move it as right as you want it to be.

<div style="position:absolute; left:-500px; top:30px;">  

etc. Obviously put the style in a seperate stylesheet but this is just a quicker example.

like image 166
dsgriffin Avatar answered Oct 24 '22 21:10

dsgriffin