inblog logo
|
p4rksk
    HTML

    부트스트랩

    박선규's avatar
    박선규
    Jan 17, 2024
    부트스트랩
    Contents
    부트 스트랩 ContainerColorsBackground ColorTableButtonNavbar 반응형 메뉴바로 적용Card, navbar, container, Pagination, flex 등을 활용한 코드
     

    부트 스트랩

    📌
    부트 스트랩은 웹 플랫폼을 쉽게 만들 수 있게 도와주는 HTMl,CSS,JS 기반 프레임워크다.
     
    W3Schools.com
    W3Schools.com

    W3Schools.com

    W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

    • “트위터(Twitter)”에서 만든 “웹 개발 프레임워크”이다.
    • 반응형 디자인을 지원하는 HTML, CSS, JavaScript의 구성 요소와 클래스를 제공한다.
    • 화면이 “12분할”로 되어있다.
    • 하이픈(-) 하나를 넣어 만들어지는데 개인이 만든 class는 충돌이 아니 않도록 “컨벤션(Convention)” 을 해야 한다.

    Container

    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container"> <h1>My First Bootstrap Page</h1> <p>This part is inside a .container class.</p> <p>The .container class provides a responsive fixed width container.</p> <p>Resize the browser window to see that the container width will change at different breakpoints.</p> </div> </body> </html>
    container 를 이용해서 가운데 정렬을 한다.
    출력 결과
    notion image
     

    Colors

    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Contextual Colors</h2> <p>Use the contextual classes to provide "meaning through colors":</p> <p class="text-muted">This text is muted.</p> <p class="text-primary">This text is important.</p> <p class="text-success">This text indicates success.</p> <p class="text-info">This text represents some information.</p> <p class="text-warning">This text represents a warning.</p> <p class="text-danger">This text represents danger.</p> <p class="text-secondary">Secondary text.</p> <p class="text-dark">This text is dark grey.</p> <p class="text-body">Default body color (often black).</p> <p class="text-light">This text is light grey (on white background).</p> <p class="text-white">This text is white (on white background).</p> </div> </body> </html>
    글자에 색상을 부여 (없는 색상은 직접 생성)
    출력 결과
    notion image
     

    Background Color

    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container bg-primary text-white"> <h1>My First Bootstrap Page</h1> <p>This part is inside a .container class.</p> <p>The .container class provides a responsive fixed width container.</p> <p>Resize the browser window to see that the container width will change at different breakpoints.</p> </div> </body> </html>
    츨력 결과
    notion image
     

    Table

    📌
    Table은 색상을 줄 때 table-primary 등으로 정해져 있다.
    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Hover Rows</h2> <p>The .table-hover class enables a hover state (grey background on mouse over) on table rows:</p> <table class="table table-hover"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>Doe</td> <td>john@example.com</td> </tr> <tr> <td>Mary</td> <td>Moe</td> <td>mary@example.com</td> </tr> <tr> <td>July</td> <td>Dooley</td> <td>july@example.com</td> </tr> </tbody> </table> </div> </body> </html>
    출력 결과
    notion image
     

    Button

    📌
    <button type="button" class="btn btn-primary">Primary</button> 에서 ”btn-outline-primay"로 class를 바꾸면 색이 바깥 선에만 적용된다.
    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Button Styles</h2> <button type="button" class="btn">Basic</button> <button type="button" class="btn btn-outline-primary">Primary</button> <button type="button" class="btn btn-secondary">Secondary</button> <button type="button" class="btn btn-success">Success</button> <button type="button" class="btn btn-info">Info</button> <button type="button" class="btn btn-warning">Warning</button> <button type="button" class="btn btn-danger">Danger</button> <button type="button" class="btn btn-dark">Dark</button> <button type="button" class="btn btn-light">Light</button> <button type="button" class="btn btn-link">Link</button> </div> </body> </html>
    출력 결과
    notion image
     
     

    Navbar 반응형 메뉴바로 적용

    📌
    위를 제외하고 많이 쓰는 것! Pagination, List Groups, Cards, Flex, Utilities 등이 있다.
    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <nav class="navbar navbar-expand-sm bg-dark navbar-dark"> <div class="container-fluid"> <a class="navbar-brand" href="/">홈</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="collapsibleNavbar"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="#">로그인</a> </li> <li class="nav-item"> <a class="nav-link" href="#">회원가입</a> </li> <li class="nav-item"> <a class="nav-link" href="#">로그아웃</a> </li> </ul> </div> </div> </nav> </body> </html>
    출력 결과
    notion image
    notion image
     
     

    Card, navbar, container, Pagination, flex 등을 활용한 코드

    코드
    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> <style> .card_box { margin-top: 10px; display: grid; grid-template-columns: repeat(3, auto); grid-gap: 10px; } </style> </head> <body> <nav class="navbar navbar-expand-sm bg-dark navbar-dark"> <div class="container-fluid"> <a class="navbar-brand" href="/">홈</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="collapsibleNavbar"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="#">로그인</a> </li> <li class="nav-item"> <a class="nav-link" href="#">회원가입</a> </li> <li class="nav-item"> <a class="nav-link" href="#">로그아웃</a> </li> </ul> </div> </div> </nav> <div class="container"> <div class="d-flex justify-content-end mt-3 mb-3"> <form class="d-flex" style="width: 300px;"> <input class="form-control me-2" type="text" placeholder="Search"> <button class="btn btn-primary" type="button">Search</button> </form> </div> <div class="card_box"> <div class="card"> <div class="card-body"> <h4 class="card-title">John Doe</h4> <p class="card-text">Some example text.</p> <a href="#" class="btn btn-primary">See Profile</a> </div> </div> <div class="card"> <div class="card-body"> <h4 class="card-title">John Doe</h4> <p class="card-text">Some example text.</p> <a href="#" class="btn btn-primary">See Profile</a> </div> </div> <div class="card"> <div class="card-body"> <h4 class="card-title">John Doe</h4> <p class="card-text">Some example text.</p> <a href="#" class="btn btn-primary">See Profile</a> </div> </div> <div class="card"> <div class="card-body"> <h4 class="card-title">John Doe</h4> <p class="card-text">Some example text.</p> <a href="#" class="btn btn-primary">See Profile</a> </div> </div> <div class="card"> <div class="card-body"> <h4 class="card-title">John Doe</h4> <p class="card-text">Some example text.</p> <a href="#" class="btn btn-primary">See Profile</a> </div> </div> <div class="card"> <div class="card-body"> <h4 class="card-title">John Doe</h4> <p class="card-text">Some example text.</p> <a href="#" class="btn btn-primary">See Profile</a> </div> </div> </div> <ul class="pagination d-flex justify-content-center"> <li class="page-item disabled"><a class="page-link" href="#">Previous</a></li> <li class="page-item"><a class="page-link" href="#">Next</a></li> </ul> </div> <div class="bg-light p-5 text-center"> <h4>Created by Metacoding</h4> <h5>☎ 010-2222-7777</h5> <button class="btn btn-outline-primary">고객센터</button> <button class="btn btn-outline-primary">오시는길</button> </div> </body> </html>
    출력 결과
    notion image
     
    Share article

    p4rksk

    RSS·Powered by Inblog