Style Sheet/CSS

๐ŸŽจ ๋ฆฌ์ŠคํŠธ(list) ์Šคํƒ€์ผ ์†์„ฑ ๋ชจ์Œ

์ธํŒŒ_ 2021. 10. 1. 17:43

๋ฆฌ์ŠคํŠธ-์Šคํƒ€์ผ

๋ชฉ๋ก ๊ด€๋ จ CSS ์†์„ฑ

<body>

    <ul>
        <li>์•„๋ฉ”๋ฆฌ์นด๋…ธ</li>
        <li>์นดํŽ˜๋ผ๋–ผ</li>
        <li>ํ•ซ์ดˆ์ฝ”</li>
    </ul>

    <ol>
        <li>์•„๋ฉ”๋ฆฌ์นด๋…ธ</li>
        <li>์นดํŽ˜๋ผ๋–ผ</li>
        <li>ํ•ซ์ดˆ์ฝ”</li>
    </ol>

</body>

๋ฆฌ์ŠคํŠธ-์Šคํƒ€์ผ


lists ์†์„ฑ ์ข…๋ฅ˜

์†์„ฑ ์„ค๋ช…
list-style ๋ชจ๋“  list-style ์†์„ฑ์„ ์ด์šฉํ•œ ์Šคํƒ€์ผ์„ ํ•œ ์ค„์— ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Œ.
list-style-type ๋ฆฌ์ŠคํŠธ ์š”์†Œ์˜ ๋งˆ์ปค(marker)๋ฅผ ์„ค์ •ํ•จ.
list-style-image ๋ฆฌ์ŠคํŠธ ์š”์†Œ์˜ ๋งˆ์ปค๋กœ ์‚ฌ์šฉํ•  ์ด๋ฏธ์ง€๋ฅผ ์„ค์ •ํ•จ.
list-style-position ๋ฆฌ์ŠคํŠธ ์š”์†Œ์˜ ์œ„์น˜๋ฅผ ์„ค์ •ํ•จ.

โ€‹

list-style-image

: ๋ชฉ๋ก ๋งˆ์ปค๋ฅผ ์ด๋ฏธ์ง€๋กœ ์‚ฌ์šฉ

  • none : ์ด๋ฏธ์ง€๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
  • url : ์‚ฌ์šฉํ•  ์ด๋ฏธ์ง€์˜ URL์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
  • initial : ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
ul {
   list-style-image: url("../../media/examples/rocket.svg");
}

๋ฆฌ์ŠคํŠธ-์Šคํƒ€์ผ

 

list-style-position

: ๋ชฉ๋ก ๋งˆ์ปค ์œ„์น˜ ์กฐ์ •

  • inside : ๋ฌธ๋‹จ ์•ˆ์ชฝ์— ๋†“์Šต๋‹ˆ๋‹ค.
  • outside : ๋ฌธ๋‹จ ๋ฐ”๊นฅ์ชฝ์— ๋†“์Šต๋‹ˆ๋‹ค.
<ul class="inside">List 1
  <li>List Item 1-1</li>
  <li>List Item 1-2</li>
  <li>List Item 1-3</li>
  <li>List Item 1-4</li>
</ul>
<ul class="outside">List 2
  <li>List Item 2-1</li>
  <li>List Item 2-2</li>
  <li>List Item 2-3</li>
  <li>List Item 2-4</li>
</ul>
.inside {
  list-style-position: inside;
  list-style-type: square;
}

.outside {
  list-style-position: outside;
  list-style-type: circle;
}

๋ฆฌ์ŠคํŠธ-์Šคํƒ€์ผ

 

list-style-type

: ๋ชฉ๋ก์˜ ๋งˆ์ปค ๋ชจ์–‘ ํƒ€์ž…

ํƒœ๊ทธ ํŒŒ๋ผ๋ฏธํ„ฐ
ul disc, circle, square
ol decimal, decimal-leading-zero, lower-roman, upper-roman, lower-greek, lower-latin, upper-latin, armenian, georgian, lower-alpha, upper-alpha
โ€‹ none

๋ฆฌ์ŠคํŠธ-์Šคํƒ€์ผ

โ€‹

list-style

: type, position,url ํ•œ๊บผ๋ฒˆ์— ์„ค์ • ๊ฐ€๋Šฅ

list-style: square inside url("../img/icon.png");

ul,ol ๊ฐ€์šด๋ฐ ์ •๋ ฌ

โ€‹

๋ชฉ๋ก์˜ ๋‚ด์šฉ๋งŒ ๊ฐ€์šด๋ฐ ์ •๋ ฌ

ul {
  text-align: center;
}

โ€‹

๋ชฉ๋ก ์š”์†Œ ์ž์ฒด๋ฅผ ๊ฐ€์šด๋ฐ ์ •๋ ฌ

๋ชฉ๋ก ์š”์†Œ ์ž์ฒด๋ฅผ ๊ฐ€์šด๋ฐ ์ •๋ ฌํ•  ๋•Œ๋Š” margin ์†์„ฑ์„ ์‚ฌ์šฉํ•œ๋‹ค.

ul, ol์˜ ๊ธฐ๋ณธ ๊ฐ€๋กœ ํฌ๊ธฐ๋Š” 100%์ด๋ฏ€๋กœ, ๊ฐ€๋กœ ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•ด์ค˜์•ผ ๊ฐ€์šด๋ฐ๋กœ ์ •๋ ฌ๋œ๋‹ค.

ul {
  width: 300px;
  margin-left: auto;
  margin-right: auto;
}

๋งŒ์•ฝ ์š”์†Œ์˜ ๋‚ด์šฉ์— ๋งž๊ฒŒ ์ž๋™์œผ๋กœ ํฌ๊ธฐ๊ฐ€ ์ •ํ•ด์ง€๊ฒŒ ํ•˜๊ณ  ์‹ถ์œผ๋ฉด display ์†์„ฑ์„ ์‚ฌ์šฉํ•œ๋‹ค.

ul {
  display: table;
  margin-left: auto;
  margin-right: auto;
}

ul.a {
   text-align: center;
}
ul.b {
   width: 300px;
   margin-left: auto;
   margin-right: auto;
}
ul.c {
   display: table;
   margin-left: auto;
   margin-right: auto;
}

๋ฆฌ์ŠคํŠธ-์Šคํƒ€์ผ


# ์ฐธ๊ณ ์ž๋ฃŒ

https://www.codingfactory.net/10774

https://tcpschool.com/css/css_basic_lists