potato potato - 18 days ago 9
CSS Question

How to make section 100% size with margins?

I want a border with pictures and parallax scrolling, so i added a section in the body and had the content in that. but when i make the section 100% or 100vh and add margin it goes outside the body.

Answer

You need the section as full height with 20px margin. So i have added the fiddle here

And the code here

<body style="margin:0;background: red; width:100%;height:100%;">

    <section style="position: absolute; display: inline-block; top:0; left:0; bottom:0; width:200px;  margin:20px; background:green;">

    </section>
</body>
Comments