Search

Margin inherit

HTML

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>margin inherit</title> <link rel="stylesheet" href="css/03_margin_inherit.css"> </head> <body> <center><h1>margin inherit</h1></center> <div class="container"> <!-- (section>h2{margin : inherit;})*3 --> <section> <h2>margin : inherit;</h2> </section> <section> <h2>margin : inherit;</h2> </section> <section> <h2>margin : inherit;</h2> </section> </div> </body> </html>
HTML
๋ณต์‚ฌ

CSS

.container { position: relative; width: 1200px; border: 3px dashed orange; margin: auto; } section { /* inherit : ๋ถ€๋ชจ์š”์†Œ์˜ ์ง€์ •๊ฐ’์„ ๋ฌผ๋ ค๋ฐ›์•„์„œ ์ ์šฉ */ /* ๋ถ€๋ชจ์š”์†Œ : container ์ž์‹์š”์†Œ : section */ width: 900px; height: 200px; border: 3px solid gray; margin: inherit; /* ๋ถ€๋ชจ์š”์†Œ๋กœ๋ถ€ํ„ฐ ์ƒ์†๋ฐ›์•„ auto ๊ฐ€ ์ ์šฉ๋จ */ }
CSS
๋ณต์‚ฌ