C
C
Captain Cocoa2015-09-23 15:55:22
css
Captain Cocoa, 2015-09-23 15:55:22

How to indent a div from the parent and not from the edge of the body?

Look, there is one div and the second one is nested inside it.
The second has a 20px padding from the top.
But the indent is not from the parent to the nested block, but from the body to the parent block.
How to fix it?
For clarity , here's an example : jsfiddle.net/5pdfduyw/1
And I'll show you how it is and how it should be in the image.
36c4ef8abb4a4adb82a18b5229bc238c.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
@
@kotmail, 2015-09-23
@RadCor

jsfiddle.net/5pdfduyw/2

G
Gregory, 2015-09-23
@grigruss

body {margin:0px;padding:0px;}
.box1 {width:200px;height:200px;background:#ff0000;padding:20px 0;}
.box2 {width:100px;height:100px;background:#0000ff;}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question