HTML CSS JS | BootStrap

ํŒŒ๊ณผยท2022๋…„ 8์›” 3์ผ

HTML CSS JS

๋ชฉ๋ก ๋ณด๊ธฐ
1/3
post-thumbnail

๐Ÿ”— ์ฝ”๋“œ ์ฐธ๊ณ 

1. ์‹œ์ž‘ํ•˜๊ธฐ

์ฐธ๊ณ  http://bootstrapk.com/getting-started/

1.1. ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ <head>์— ๋„ฃ๊ณ  ์‹œ์ž‘.

<!-- ํ•ฉ์ณ์ง€๊ณ  ์ตœ์†Œํ™”๋œ ์ตœ์‹  CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- ๋ถ€๊ฐ€์ ์ธ ํ…Œ๋งˆ -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

<!-- ํ•ฉ์ณ์ง€๊ณ  ์ตœ์†Œํ™”๋œ ์ตœ์‹  ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

1.2. jQuery ์‚ฌ์šฉ์„ ์œ„ํ•ด ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋งํฌ ๋งจ ์œ„์— ๋„ฃ์–ด์ค€๋‹ค.

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

1.3. container class๋กœ ๊ผญ ๋ฌถ์–ด์ค˜์•ผ ํ•œ๋‹ค.

<div class="container"></div>

2. ํฌ๊ธฐ ํ‘œํ˜„

2.1. ํฌ๊ธฐ ๊ตฌ๋ถ„

  • sm(small), md(middle), lg(large)
  • ์ ์šฉ ๋Œ€์ƒ - ํฌ๊ธฐ - ์ˆซ์ž(์นธ์ˆ˜)๋กœ ํ‘œํ˜„ํ•œ๋‹ค.
  • ์˜ˆ : col-xs-1
  • container๋Š” bootstrap์—์„œ ์ •ํ•œ column 12์นธ์„ ๊ธฐ์ค€์œผ๋กœ ํ•œ๋‹ค.

์ฝ”๋“œ ์˜ˆ์‹œ

<style>
        .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
          border: 1px solid red;
          padding: 10px;
        }
        .row{
          margin-bottom: 4px;
          margin-top: 4px;
          }
      </style>
</head>
<body>
    <div class="container">
        <div class="row">
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
          <div class="col-md-1">.col-md-1</div>
        </div>
        <div class="row">
          <div class="col-md-8">.col-md-8</div>
          <div class="col-md-4">.col-md-4</div>
        </div>
        <div class="row">
          <div class="col-md-4">.col-md-4</div>
          <div class="col-md-4">.col-md-4</div>
          <div class="col-md-4">.col-md-4</div>
        </div>
        <div class="row">
          <div class="col-md-6">.col-md-6</div>
          <div class="col-md-6">.col-md-6</div>
        </div>
      </div>
</body>

3. offset

์นธ์„ ๋„์šฐ๋Š” ๊ธฐ๋Šฅ.

์ฝ”๋“œ ์˜ˆ์‹œ

<div class="container">       
        <div class="row">
          <div class="col-md-5"> .col-md-5    </div>
          <div class="col-md-5 col-md-offset-2"> .col-md-5 col-md-offset-2      </div>
        </div>  
        <div class="row">
          <div class="col-md-4"> .col-md-4    </div>
          <div class="col-md-7 col-md-offset-1"> .col-md-7 .col-md-offset-1     </div>
        </div>      
      </div>

4. Grid Layout

  • ๊ทธ๋ฆฌ๋“œ ์‹œ์Šคํ…œ์„ ์ด์šฉํ•œ ๋ ˆ์ด์•„์›ƒ.
  • 960gs์™€ ์œ ์‚ฌํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.
  • push : ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋ฐ€๊ธฐ
  • pull : ์™ผ์ชฝ์œผ๋กœ ๋‹น๊ธฐ๊ธฐ

์ฝ”๋“œ ์˜ˆ์‹œ

<div class="container">       
        <header>
          <h2>๊ทธ๋ฆฌ๋“œ ์‹œ์Šคํ…œ์„ ์ด์šฉํ•œ ๋ ˆ์ด์•„์›ƒ </h2>
        </header>
         <div class="row">
           <div class="col-md-2 col-md-push-10">
             <ul class="nav">
               <li>menu 1</li>
               <li>menu 2</li>
               <li>menu 3</li>
               <li>menu 4</li>
             </ul>
           </div>
           <div class="col-md-10 cont col-md-pull-2">
            <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris rutrum vitae lectus sit amet tincidunt. Aliquam id fringilla sapien. Mauris eu nulla at nunc mollis pharetra. Fusce iaculis lectus nec enim feugiat luctus. Nunc tempor orci auctor iaculis consectetur. Cras pellentesque lorem sit amet tempor convallis. Sed ut cursus urna, sed adipiscing elit. Curabitur sit amet adipiscing felis. Duis pellentesque justo quam. Integer lobortis vehicula mauris, at ornare turpis consectetur at. Duis tristique velit tortor, quis viverra dolor venenatis eget.</p>
     
             <p>Nunc venenatis laoreet ullamcorper. Fusce at orci vulputate, mattis neque vel, euismod ipsum. Proin varius metus neque. In congue, arcu eu posuere gravida, erat sem auctor orci, eu convallis tortor est id sapien. Phasellus gravida quam est, et posuere diam cursus ut. Donec et ipsum laoreet, mattis mauris sit amet, suscipit augue. Etiam vel massa consequat leo pulvinar fermentum a vel urna. Duis malesuada tincidunt tortor id mattis. Sed facilisis massa libero, ut cursus turpis molestie a. Sed ornare, nibh et suscipit semper, sapien lorem auctor nisl, et volutpat lacus quam sit amet mauris.</p>
           </div>
        
         </div>
         <hr>
        <footer>
          ์—ฌ๊ธฐ๋Š” ํ‘ธํ„ฐ๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” ๊ณณ์ž…๋‹ˆ๋‹ค.
        </footer>
       </div>

5. Table

5.1. ๊ธฐ๋ณธ ํ…Œ์ด๋ธ”

<h4 class="text-primary">๊ธฐ๋ณธ table ์ฝ”๋“œ</h4>
<table>
  <thead>
    <tr>
      <th>๋ฒˆ ํ˜ธ </th>
      <th>์ œ ๋ชฉ</th>
      <th>๊ธ€์“ด์ด</th>
    </tr>
  </thead>
  <tr>
    <td>1</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ </td>
    <td>ํ™๊ธธ๋™</td>
  </tr>
  <tr>
    <td>2</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์ž„๊บฝ์ • </td>
  </tr>
  <tr>
    <td>3</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์„ฑ์ถ˜ํ–ฅ </td>
  </tr>   
</table>

5.2. class=โ€tableโ€

<h4 class="text-primary">table class="table" ์ ์šฉ์‹œ</h4>
<table class="table">
  <thead>
    <tr>
      <th>๋ฒˆ ํ˜ธ </th>
      <th>์ œ ๋ชฉ</th>
      <th>๊ธ€์“ด์ด</th>
    </tr>
  </thead>
  <tr>
    <td>1</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ </td>
    <td>ํ™๊ธธ๋™</td>
  </tr>
  <tr>
    <td>2</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์ž„๊บฝ์ • </td>
  </tr>
  <tr>
    <td>3</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์„ฑ์ถ˜ํ–ฅ </td>
  </tr>   
</table>

5.3. class=โ€table table-stripedโ€

<h4 class="text-primary">table class="table table-striped" ์ ์šฉ์‹œ</h4>
<table class="table table-striped">
  <thead>
    <tr>
      <th>๋ฒˆ ํ˜ธ </th>
      <th>์ œ ๋ชฉ</th>
      <th>๊ธ€์“ด์ด</th>
    </tr>
  </thead>
  <tr>
    <td>1</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ </td>
    <td>ํ™๊ธธ๋™</td>
  </tr>
  <tr>
    <td>2</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์ž„๊บฝ์ • </td>
  </tr>
  <tr>
    <td>3</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์„ฑ์ถ˜ํ–ฅ </td>
  </tr>   
</table>

5.4. class=โ€table table hoverโ€

<h4 class="text-primary">table class="table table-hover" ์ ์šฉ์‹œ</h4>
<table class="table table-hover">
  <thead>
    <tr>
      <th>๋ฒˆ ํ˜ธ </th>
      <th>์ œ ๋ชฉ</th>
      <th>๊ธ€์“ด์ด</th>
    </tr>
  </thead>
  <tr>
    <td>1</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ </td>
    <td>ํ™๊ธธ๋™</td>
  </tr>
  <tr>
    <td>2</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์ž„๊บฝ์ • </td>
  </tr>
  <tr>
    <td>3</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์„ฑ์ถ˜ํ–ฅ </td>
  </tr>   
</table>

5.5. table class=โ€activeโ€, โ€œsuccessโ€, โ€œwarningโ€, โ€œdangerโ€

<h4 class="text-primary">table class="active" "success" "warning" "danger" ์ ์šฉ์‹œ</h4>
<table class="table table-hover">
  <thead>
    <tr class="active">
      <th>๋ฒˆ ํ˜ธ </th>
      <th>์ œ ๋ชฉ</th>
      <th>๊ธ€์“ด์ด</th>
    </tr>
  </thead>
  <tr class="success">
    <td>1</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ </td>
    <td>ํ™๊ธธ๋™</td>
  </tr>
  <tr class="warning">
    <td>2</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์ž„๊บฝ์ • </td>
  </tr>
  <tr class="danger">
    <td>3</td>
    <td>ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ  ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ</td>
    <td>์„ฑ์ถ˜ํ–ฅ </td>
  </tr>   
</table>

6. ๋ฒ„ํŠผ

  • aria : ์ ‘๊ทผ์„ฑ
    ์ ‘๊ทผ๊ฐ€๋Šฅํ•œ ๋ฆฌ์น˜ ์ธํ„ฐ๋„ท ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ - ์žฅ์• ๋ฅผ ๊ฐ€์ง„ ์‚ฌ์šฉ์ž๊ฐ€ ์›น ์ฝ˜ํ…์ธ ์™€ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜(ํŠนํžˆ JavaScript๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐœ๋ฐœํ•œ ๊ฒฝ์šฐ)์— ๋” ์‰ฝ๊ฒŒ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•˜๋Š” ์—ฌ๋Ÿฌ ํŠน์„ฑ์„ ๋งํ•ฉ๋‹ˆ๋‹ค.
  • aria-hidden: ์ œ์ž‘์ž๊ฐ€ ์‹œ๊ฐ์ ์œผ๋กœ๋„, ์Šคํฌ๋ฆฐ ๋ฆฌ๋”์—์„œ๋„ ์ˆจ๊ธฐ๊ณ  ์‹ถ์€ ์ฝ˜ํ…์ธ 
  • ์•„๋ž˜ ์ฝ”๋“œ์—์„œ๋Š” ๋ฒ„ํŠผ ๋ชจ์–‘ ์‚ญ์ œ

์ฝ”๋“œ ์˜ˆ์‹œ

<style>
  .box {
  width: 200px;
  border: 1px solid #ccc;
  height: 100px;
  }
</style>

<div class="container">
  <h5>๋‹ซ๊ธฐ๋ฒ„ํŠผ</h5>
  <div class="box">
    <button type="button" class="close" aria-hidden="true">x</button>
  </div>
</div>

7. form

์ฝ”๋“œ ์˜ˆ์‹œ

<div class="container">
  <form role="form">
    <div class="form-group">
      <label for="name">์ด๋ฆ„</label>
      <input type="text" class="form-control" placeholder="์ด๋ฆ„">
    </div>
    <div class="form-group">
      <label for="name">์ด๋ฉ”์ผ</label>
      <input type="email" class="form-control" placeholder="์ด๋ฉ”์ผ">
    </div>
    <div class="form-group">
      <button type="submit">ํ™•์ธ</button>
    </div>
  </form>

  <form role="form" class="form-inline">
    <div class="form-group">
      <label for="name" class="sr-only">์ด๋ฆ„</label>
      <input type="text" class="form-control" placeholder="์ด๋ฆ„">
    </div>
    <div class="form-group">
      <label for="name">์ด๋ฉ”์ผ</label>
      <input type="email" class="form-control" placeholder="์ด๋ฉ”์ผ">
    </div>
    <div class="form-group">
      <button type="submit">ํ™•์ธ</button>
    </div>
  </form>
</div>

8. container

https://getbootstrap.kr/docs/5.0/layout/containers/

0๊ฐœ์˜ ๋Œ“๊ธ€