π₯ block-level & inline-level λ?
π₯ display μμ±
π₯ visibility μμ±
π₯ inline-block νΉμ§
1) block-levelμ νΉμ±
- νμ μλ‘μ΄ λΌμΈμ λ€μ νκ·Έλ₯Ό μμΉμν΄
- νλ©΄μ λλΉ μ 체λ₯Ό μ°¨μ§
- width, height, margin, padding μμ± μ€μ κ°λ₯
- block μμ μμ inline μμ ν¬ν¨ κ°λ₯
- defaulκ°μΌλ‘ block-level νΉμ±μ κ°μ§ νκ·Έ : div / h1~h6 / p, ol, ul, li, hr, table, form λ±
2) inline-levelμ νΉμ±
- κ°μ λΌμΈμ λ€λ₯Έ μμμ μ°μ΄μ΄ μμΉ κ°λ₯
- content λλΉλ§νΌ κ°λ‘νμ κ°μ§
- width, height, margin, padding λ±μ μμ± μ€μ λΆκ°λ₯
- μν μ¬λ°±μ line-heightλ‘ μ§μ κ°λ₯
- inline νΉμ±μ κ°μ§ νκ·Έ μμ block νΉμ±μ κ°μ§ μμ ν¬ν¨ λΆκ°λ₯
- defaulκ°μΌλ‘ inline-level νΉμ±μ κ°μ§ νκ·Έ : span / a / strong / img / br / input / select / textarea / button λ±
βπ» html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <style> .spantag { background-color: tomato; } .divtag { background-color: aquamarine; } </style> </head> <body> <h2>div νκ·Έ μμ span νκ·Έ</h2> <div class="spantag"> μ΄κ² λΆλΆμ div νκ·Έλ‘ λ¬ΆμΈ ν λ¬Έμ₯μ λλ€. <span>"μ΄ λΆλΆμλ§ span νκ·Έλ‘ κ°μΈμ Έ μμ΅λλ€."</span> spanμ inline-block μμμ΄κΈ° λλ¬Έμ μ€ λ°κΏμ΄ λμ§ μμ΅λλ€. </div> <h2>span νκ·Έ μμ div νκ·Έ</h2> <span class="divtag"> μ΄κ² λΆλΆμ span νκ·Έλ‘ λ¬ΆμΈ λ¬Έμ₯μ λλ€. <div>"μ΄ λΆλΆλ§ divνκ·Έλ‘ κ°μΈμ Έ μμ΅λλ€."</div> divλ block-level μμμ΄κΈ° λλ¬Έμ λͺ¨λ μμμ μ°¨μ§νμ¬ μ€λ°κΏμ΄ λ©λλ€. </span> </body> </html>
βπ» html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <style> body { display: flex; } div { width: 300px; } span { background-color: tomato; } strong { background-color: aquamarine; } .display_none { display: none; } .visibility_hidden { visibility: hidden; } </style> </head> <body> <div> <span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt facere iusto provident corporis? Nulla, exrerum voluptatem fuga rem saepe, quis, voluptatibus nihil consequuntur tempore repellat accusantium ab? Totam,tempora.</span> <strong>Can you see me? Can you see me? Can you see me? Can you see me?</strong> <span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt facere iusto provident corporis? Nulla, exrerum voluptatem fuga rem saepe, quis, voluptatibus nihil consequuntur tempore repellat accusantium ab? Totam,tempora.</span> </div> <div> <span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt facere iusto provident corporis? Nulla, exrerum voluptatem fuga rem saepe, quis, voluptatibus nihil consequuntur tempore repellat accusantium ab? Totam,tempora.</span> <strong class="display_none">Can you see me? Can you see me? Can you see me? Can you see me?</strong> <span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt facere iusto provident corporis? Nulla, exrerum voluptatem fuga rem saepe, quis, voluptatibus nihil consequuntur tempore repellat accusantium ab? Totam,tempora.</span> </div> <div> <span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt facere iusto provident corporis? Nulla, exrerum voluptatem fuga rem saepe, quis, voluptatibus nihil consequuntur tempore repellat accusantium ab? Totam,tempora.</span> <strong class="visibility_hidden">Can you see me? Can you see me? Can you see me? Can you see me?</strong> <span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt facere iusto provident corporis? Nulla, exrerum voluptatem fuga rem saepe, quis, voluptatibus nihil consequuntur tempore repellat accusantium ab? Totam,tempora.</span> </div> </body> </html>
βπ» html
<!DOCTYPE html> <html lang="en"> <head> <style> body { margin: 20px; } div { display: inline-block; width: 300px; height: 300px; background-color: teal; margin-right: 10.01; } </style> </head> <body> <div></div> <div></div> <div></div> <div></div> <div></div> </body> </html>