728x90
이번 시간에는 Bootstrap으로 웹페이지에서 네비게이션 드로어를 만드는 예제를 진행하겠습니다.
1. 준비
Bootstrap은 프론트엔드 툴킷으로, 프론트엔드를 빠르고 예쁘게 만드는데 유용합니다.
이 예제에서는 CDN 링크로 Bootstrap을 사용해보겠습니다.
아래의 CDN 링크를 HTML <head> 에 넣어줍니다.
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/docs/5.3/assets/css/docs.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"></script>
2. 소스 코드
전체 코드입니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/docs/5.3/assets/css/docs.css" rel="stylesheet">
<title>Bootstrap NavigationBar Test</title>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body class="p-3 m-0 border-0 bd-example m-0 border-0">
<nav class="navbar navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand p-3" href="#">스틱코드 네비게이션 바 테스트</a>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDarkNavbar" aria-controls="offcanvasDarkNavbar" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasDarkNavbar" aria-labelledby="offcanvasDarkNavbarLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasDarkNavbarLabel">네비게이션 바</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#HOME">홈</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#LINK">링크</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
서랍
</a>
<ul class="dropdown-menu dropdown-menu-dark">
<li><a class="dropdown-item" href="#">정보 1</a></li>
<li><a class="dropdown-item" href="#">정보 2</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">다른 것들</a></li>
</ul>
</li>
</ul>
<form class="d-flex mt-3" role="search">
<input class="form-control me-2" type="search" placeholder="검색어 입력" aria-label="Search">
<button class="btn btn-success" type="submit">Search</button>
</form>
</div>
</div>
</div>
</nav>
</body>
</html>
3. 실행 결과
'HTML/CSS' 카테고리의 다른 글
[HTML/CSS] Bootstrap으로 아코디언 만들기 (0) | 2024.03.12 |
---|---|
[HTML/CSS] CTA 만들기 (0) | 2024.03.07 |
[HTML/CSS] 슬라이드쇼 만들기 (0) | 2024.02.16 |
[HTML/CSS] 탭 메뉴 만들기 (0) | 2024.02.07 |
[HTML/CSS] 세로 드롭다운 메뉴 (0) | 2024.02.06 |