Click here to Skip to main content
15,441,434 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to give mergin only for child. And for this margin the chld box will go outsite of the parent box. But Its doesn't working!

What I have tried:

CSS
.parent {
	background: green;
	width: 300px;
	height: 150px;
	display: block;
	position:absulate;
}
.child {
	background: red;
	width: 150px;
	height: 75px;
	display: block;
	margin-top: 200px
	
	/*
	I want to give mergin only for child.
	And for this margin the chld box will go outsite of the parent box.
	But Its doesn't working!
	*/
}
HTML
<div class="parent">
    <div class="child">
        Move this div
    </div>
</div>
Posted
Updated 28-Apr-22 1:12am
v3

This is something you can play with in right in the browser; by using the Inspect feature which will bring up a console at the bottom where you can explored the elements of the page and the styles that are applied.

In the case of your code; this line is crossed out: position:absulate;
I edited it in the browser to absolute.. and the parent div moved up and the child was now out of the box
 
Share this answer
 
make parent div

position: relative;

and
child div.

position: absolute;

and set top bottom right left .. to set the postion ..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900