여러분이 사용하고 계신 브라우저는 HTML5를 지원하지 않기 때문에 몇몇 요소가 제대로 보이도록 JScript를 사용하고 있습니다. 하지만 여러분의 브라우저 설정에서 스크립트 기능이 꺼져있으므로, 현재 페이지를 제대로 확인하시려면 스크립트 기능을 켜주셔야 합니다. How To - 동일한 너비 Navbar 링크
How To – 동일한 너비 Navbar 링크
5개월전 작성
5개월전 수정

w3.css

동일한 너비 Navbar 링크

너비가 같은 탐색 링크가 있는 탐색 모음을 만드는 방법을 알아보자.

반응형 탐색 모음 만들기

1단계) HTML 추가
<!-- The navigation menu -->
<div class="navbar">
  <a class="active" href="#">Home</a>
  <a href="#">Search</a>
  <a href="#">Contact</a>
  <a href="#">Login</a>
</div>
2단계) CSS 추가
/* Style the navigation menu */
.navbar {
  width: 100%;
  background-color: #555;
  overflow: auto;
}

/* Navigation links */
.navbar a {
  float: left;
  padding: 12px;
  color: white;
  text-decoration: none;
  font-size: 17px;
  width: 25%; /* Four equal-width links. If you have two links, use 50%, and 33.33% for three links, etc.. */
  text-align: center; /* If you want the text to be centered */
}

/* Add a background color on mouse-over */
.navbar a:hover {
  background-color: #000;
}

/* Style the current/active link */
.navbar a.active {
  background-color: #04AA6D;
}

/* Add responsiveness - on screens less than 500px, make the navigation links appear on top of each other, instead of next to each other */
@media screen and (max-width: 500px) {
  .navbar a {
    float: none;
    display: block;
    width: 100%;
    text-align: left; /* If you want the text to be left-aligned on small screens */
  }
}
기본 예시
예제 보기

아이콘이 있는 동일한 너비 탐색 링크

기본 예시
예제 보기
참고
Mingg`s Diary
밍구
공부 목적 블로그