Error in margin right property in CSS [Resolved]

Posted by Klbaiju under ASP.NET on 1/25/2016 | Points: 10 | Views : 540 | Status : [Member] | Replies : 2
Hi following is my complete html.

<html>
<head>
<style type="text/css">
#div1{width:1000px;height:700px;border:1px solid blue;margin:0px auto;}
#div2{width:200px;height:300px;border:1px solid blue; margin-right:10px; margin-top:10px;}
</style>
</head>
<body>

<div id="div1">

<div id="div2">
</div>
</div>




</body>
</html>

the problem is div2 has margin-right property of 10px.

but it is not working.div2 still displays in left side.

how to solve this

Regards

Baiju




Responses

Posted by: Manideepgoud on: 1/26/2016 [Member] Starter | Points: 50

Up
0
Down

Resolved
<style type="text/css">
#div1 {
width: 1000px;
height: 700px;
border: 1px solid blue;
margin: 0px auto;
}

#div2 {
width: 200px;
height: 300px;
border: 1px solid blue;
margin-left: 680px;
margin-top: 10px;
}
</style>
<div id="div1"></div>


<div id="div2"></div>


Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 1/25/2016 [Member] [MVP] Silver | Points: 25

Up
0
Down
if you want to move the div2 to right then you need to set margin-left instead of margin-right.

Update css
<style type="text/css">

#div1{width:1000px;height:700px;border:1px solid blue;margin:0px auto;}
#div2{width:200px;height:300px;border:1px solid blue; margin-left:50px; margin-top:10px;}
</style>


Thanks,
A2H
My Blog

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response