html - Nested div applying margin outside box model -
i'm having trouble adding margin <figure>
while nested within <header>
.
when apply margin-top:10px
applying whole body instead of inside <header>
tag. using reset.css
if helps @ all.
this assignment in college , can't hold of tutor answer.
code:
<html> <body> <header> <figure></figure> </header> </body> </html>
css:
body { backround-color: #f2f2f2; margin:0px; padding:0px; } header { display: block; position: static; max-width: 980px; height: 100px; background: #1e1e1e; margin:0px auto 0px auto; } header figure { margin-top:10px; /** when margin top added creates margin on full page instead of inside header**/ margin-left:10px; max-width:200px; height:80px; background:red; }
add padding
header
instead. use box-sizing:border-box
prevent padding extending outward:
header { display: block; position: static; max-width: 980px; height: 100px; background: #1e1e1e; margin:0px auto; padding: 10px 0 0 10px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
Comments
Post a Comment