CSS 사용 예제

body {
  background: #d4d4d4;
  font-family: 'Malgun Gothic',Gulim,GulimChe,Dotum,DotumChe;
  font-weight: 400;
  font-size: 14px;
  line-height: 26px;
  color: #666;
}


■ 네이게이션 드롭다운 메뉴 예제

https://www.w3schools.com/howto/howto_js_responsive_navbar_dropdown.asp

/* Add a black background color to the top navigation */
.topnav {
  background-color: #333;
  overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Add an active class to highlight the current page */
.active {
  background-color: #4CAF50;
  color: white;
}

/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
  display: none;
}

/* Dropdown container - needed to position the dropdown content */
.dropdown {
  float: left;
  overflow: hidden;
}

/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

/* Style the dropdown content (hidden by default) */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

/* Style the links inside the dropdown */
.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

/* 마우스 hover 시 드롭다운 링크에 회색 배경 추가 */
.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

/* 사용자가 드롭다운 버튼 위로 마우스를 이동할 때 드롭다운 메뉴 표시 */
.dropdown:hover .dropdown-content {
  display: block;
}

/* 화면의 폭이 600픽셀 미만이면 첫 번째 링크("Home")를 제외한 모든 링크를 숨기십시오. Topnav를 열고 닫아야 하는 링크 표시 (.icon) */
@media screen and (max-width: 600px) {
  .topnav a:not(:first-child), .dropdown .dropbtn {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
  }
}

/* "responsive" 클래스는 사용자가 아이콘을 클릭하면 JavaScript를 사용하여 상위 Nav에 추가된다. 이 클래스는 작은 화면에서 Topnav를 보기 좋게 만든다(링크를 수평이 아닌 수직으로 표시) */
@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown {float: none;}
  .topnav.responsive .dropdown-content {position: relative;}
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}
위로 스크롤