Click here to Skip to main content
14,577,932 members
Rate this:
Please Sign up or sign in to 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:

.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!
	*/
}
<div class="parent">
    <div class="child">
        Move this div
    </div>
</div>
Posted
Updated 22-May-20 11:55am
v3

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100