CSS Navigation Bar
νμ€ ν

<body> <ul> <li><a href="#Home"> Home </a></li> <li><a href="#News"> News </a></li> <li><a href="#Contact"> Contact </a></li> <li><a href="#About"> About </a></li> </ul> <p> μλ
νμΈμ </p> </body>
π¬ <ol> μ«μλ‘ μ λ ¬λ μμ μλ λͺ©λ‘(Ordered List)
π¬ <ul> μ μΌλ‘ μμ μλ λͺ©λ‘(Unordered List)
π¬ <li> νκ·Έλͺ©λ‘νλͺ© μ μ
π¬ <a> νμ΄νΌλ§ν¬(λ§ν¬)λ₯Ό μ μνλ νκ·Έ ( href μμ±/ target μμ±)
ul { list-style-type: none; margin: 0; padding: 0;}
π¬ list-style-type : λͺ©λ‘ μμ(<ul>, <ol>)μ κΈ°λ³Έ λͺ©λ‘ λ§μ»€(marker)λ₯Ό μ κ±°
π¬ margin: 0; padding: 0; λΈλΌμ°μ κΈ°λ³Έ κ° μ΄κΈ°ν(reset)νλ λ° μ¬μ©νκ±°λ/ μΉ νμ΄μ§μ λ μ΄μμμ μ‘°μ ν λ μ¬λ°±μ μ μ΄
CSS Vertical Navigation Bar

ul { list-style-type: none; margin: 0; padding: 0; width: 60px;} li a { display: block; background-color: #ddd;}
π¬ display : block ; : μμλ₯Ό λΈλ‘ μμ€ μμ(block-level element)λ‘ μ§μ , μλ‘μ΄ μ€μμ μμ/μ 체 λλΉ μ°¨μ§/λλΉμ λμ΄ μ‘°μ κ°λ₯/μν μ¬λ°± μΆκ° νΉμ§μ κ°μ§
π¬ width : λΈλ‘ μμλ κΈ°λ³Έ κ°μ΄ μ 체 λλΉ , λλΉλ₯Ό μ§μ ν΄μ€λ€.

ul { list-style-type: none; margin: 0; padding: 0; width: 60px;} li a { display: block; background-color: #ddd; padding: 8px, 16px; text-decoration: none; } li a:hover { background-color: #555; color: white; }
π¬ text-decoration: none; : ν
μ€νΈμ μ μ©λ κΈ°λ³Έ ν
μ€νΈ μ₯μ(underline, overline, line-through λ±)μ μ κ±°
π¬ li a:hover : λ§μ°μ€λ₯Ό ν΄λΉ μμ μλ‘ μ¬λ Έμ λμ μνλ₯Ό μ νν©λλ€.

li a.active { background-color: #04AA6D; color: white; } li a:hover:not(.active) { background-color: #555; color: white; } <li><a class="active" href="#Home"> Home </a></li>
π¬ li a.active : μ΄λ νμ΄μ§μ μλμ§ νν
π¬ li a:hover:not(.active) : (<a>) μμκ° λ§μ°μ€λ₯Ό μ¬λ Έμ λ λμμ , νΉμ ν΄λμ€(.active)κ° μ μ©λμ§ μμ κ²½μ°μλ§ μ€νμΌ μ μ©

li { text-align: center; border-bottom: 1px solid #555; } li:last-child { border-bottom: none; }
π¬ border-bottom: 1px solid #555; νλ¨ ν
λ리 λ§λ€κΈ°
π¬ li:last-child {border-bottom: none;} li μ λ§μ§λ§ μμμ 보λ λ°ν
κ° X

body{ margin:0; } ul { list-style-type: none; margin: 0; padding: 0; width: 25%; background-color: #f1f1f1; position: fixed; height: 100%; overflow: auto; } <div style="margin-left:25%;padding:1px 16px;height:1000px;"> <h2> μλ
νμΈμ </h2> <p> μλ
νμΈμ ~ λ°κ°μ΅λλ€.</p> </div>
μ 체 λμ΄ κ³ μ μ¬μ΄λ λ€λΉκ²μ΄μ
π¬body{ margin:0; } <body> μμμ λν΄ μΈλΆ μ¬λ°±(margin)μ 0μΌλ‘ μ€μ νλ κ²
π¬width: 25%; (νλ¨ div) λΆλͺ¨μμμ λλΉμ μλμ λΉμ¨λ‘ μ§μ , νλ¨ div νκ·Έμ margin κ°κ³Ό λ§μΆ°μ£Όλ©΄ λΉμ¨μ μ λκ°μΌλ‘ μμ§μ
π¬position: fixed; λ·°ν¬νΈ(Viewport)μ κ³ μ λ μμΉμ λ°°μΉνλ κ² , μ€ν¬λ‘€ ν΄λ μμ§μ΄μ§ μμ
π¬height: 100%; λΆλͺ¨ μμμ λμ΄μ μλμ μΈ λΉμ¨λ‘ μ§μ νλ κ², μ 체 λμ΄ μ¬μ©νκ² λ€λ λ» (μμμ λΆλͺ¨ μμμ λν΄ λͺ
μμ μΌλ‘ λμ΄κ° μ€μ λμ΄μμ΄μΌν¨)
π¬overflow: auto; μμμ μ½ν
μΈ κ° μμ μ μμμ λ²μ΄λ¬μ λ μ΄λ»κ² μ²λ¦¬ν μ§λ₯Ό μ§μ νλ μμ± , (μ½ν
μΈ κ° μμμ λ²μ΄λ λ μ€ν¬λ‘€λ° νμ / μ½ν
μΈ κ° μμμ λ²μ΄λμ§ μμ λλ μ€ν¬λ‘€λ° λ―Ένμ)
π¬style="margin-left:25%;
padding:1px 16px;
height:1000px; κ³ μ κ° λΆμ¬ (μ€λ²νλ‘μ°λλ©΄ μμ± μ§μ κ°λ₯ μλ¨ μ°Έκ³ )
νκ·Έ μ체μ μ€νμΌ λΆμ¬νλ λ°©λ²
Horizontal Navigation Bar
ul { list-style-type: none; margin: 0; padding: 0; } li { display: inline; }
π¬ li {display: inline;} li λ κΈ°λ³Έμ μΌλ‘ λΈλ‘μμμ΄λ€. μΈλΌμΈ(inline) μμλ‘ νμνλλ‘ μ§μ

ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; } li { float: left; } li a { display: block; padding: 8px; background: #ddd; }
π¬ overflow: hidden; =μμμ λ΄μ©μ΄ μμμ κ²½κ³λ₯Ό λ²μ΄λ κ²½μ° μ΄κ³Όλ λΆλΆμ μ¨κΈ°λ λ°©λ² (λμΉλ μ½ν
μΈ μ¨κΉ/λ μ΄μμ μν₯ / λΆλͺ¨μμ μν₯)
π¬ float: left; = μμλ₯Ό μΌμͺ½μΌλ‘ λΆμ (floating)μν€λ κ²
π¬ μ 체 λλΉ μμ μνλ©΄ ul κ°μ back-color λ£μΌλ©΄ λ¨

ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a { display: block; padding: 14px 16px; text-decoration: none; color: #fff; } li a:hover { background-color: #111; }

.active { background-color: rgb(61, 96, 96); } li a:hover:not(.active) { background-color: #111; }
π¬ μ¬μ©μκ° μ΄λ νμ΄μ§μ μλμ§ μ μ μλλ‘ νμ¬ λ§ν¬μ "νμ±" ν΄λμ€λ₯Ό μΆκ°

<li style="float:right"><a class="active" href="#About"About></a></li>
π¬ μ€λ₯Έμͺ½ λ°°μΉνκ³ μΆμ μμλ§ float κ°μ right λ‘ μ£Όλ©΄ λ¨

li { float: left; border-right: 1px solid #bbb; } li:last-child { border-right: none; }
π¬ μν ν λ리 λ§λ€κΈ°


ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; position: fixed; bottom : 0; width: 100%; } <div style="padding:20px;margin-top:30px;background-color:#1abc9c;height:1500px;"> <h1>μλ
νμΈμ μ¬λ¬λΆ</h1> <p>λ°κ°μ΅λλ€. μ’μ ν루 λμΈμ.</p>
π¬ position: fixed; = κ³ μ λ μμΉλ‘ λ°°μΉ
π¬ top : 0; = μμͺ½(top)μ λ·°ν¬νΈ μλ¨μ κ³ μ
π¬ width: 100%; = νλ©΄μ κ°λ‘νμ λ§κ² μμμ λλΉ μ€μ 100% μ 체

ul { position: -webkit-sticky; /* Safari */ position: sticky; top: 0;}
μλ¨μ λλ¬νλ©΄ λ°κ° κ³ μ λλ€.
π¬ position: -webkit-sticky; /* Safari */ = . Safariμλ -webkit- μ λμ¬κ° νμ
π¬ position: sticky; = μ€ν¬λ‘€ μμ λ΄μμ μ§μ ν μκ³κ°κΉμ§ κ³ μ λ μμΉλ‘ λ°°μΉνλ κΈ°λ₯μ μ 곡



body {margin: 0;} ul.sidenav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #d8d8d8; position: fixed; height: 100%; overflow: auto; } ul.sidenav li a { display: block; color: #000; padding: 8px 16px; text-decoration: none; } ul.sidenav li a.active { background-color: #4CAF50; color: white; } ul.sidenav li a:hover:not(.active) { background-color: #555; color: white; } div.content { margin-left: 25%; padding: 1px 16px; height: 1000px; } @media screen and (max-width: 900px) { ul.sidenav { width: 100%; height: auto; position: relative; } ul.sidenav li a { float: left; padding: 15px; } div.content {margin-left: 0;} } @media screen and (max-width: 400px) { ul.sidenav li a { text-align: center; float: none; } }
π¬ @media screen and (max-width: 900px) @media screen and (max-width: 400px) => λ―Έλμ΄ μΏΌλ¦¬λ‘ λ·°ν¬νΈ ν¬κΈ°μ λ§κ² μ€κ³νλ€.
π¬ position: fixed; => κΈ°λ³Έ κ°
height: 100%;
overflow: auto; (μμμ μμμ λ²μ΄λ κ²½μ° μ€ν¬λ‘€μ νμ)
π¬ (max-width: 900px) { => λλΉκ° 900μΌλ
position: relative; => λ€λΉλ₯Ό μλμ μμΉλ‘ μ§μ μν¨λ€. (κΈ°λ³Έ μμΉ μ μ§/μλμ μ΄λ/μμμμμ μμΉμ§μ )
float: left; => κ°λ‘ μ λ ¬
π¬ (max-width: 400px) { => λλΉκ° 400μΌλ
text-align: center;
float: none; => κΈ°λ³Έκ° μΈλ‘ μ λ ¬