문서의 선택한 두 판 사이의 차이를 보여줍니다.
다음 판 | 이전 판 | ||
wiki:css:css_note:css_dropdowns [2021/03/31 09:03] emblim98 만듦 |
wiki:css:css_note:css_dropdowns [2023/01/13 18:44] (현재) |
||
---|---|---|---|
줄 13: | 줄 13: | ||
====예제==== | ====예제==== | ||
< | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | .dropdown { | ||
+ | position: relative; | ||
+ | display: inline-block; | ||
+ | } | ||
+ | .dropdown-content { | ||
+ | display: none; | ||
+ | position: absolute; | ||
+ | background-color: | ||
+ | min-width: 160px; | ||
+ | box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); | ||
+ | padding: 12px 16px; | ||
+ | z-index: 1; | ||
+ | } | ||
+ | |||
+ | .dropdown: | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <div class=" | ||
+ | < | ||
+ | <div class=" | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
</ | </ | ||
+ | \\ | ||
+ | ====예제 설명==== | ||
+ | **%%HTML)%%** 예를 들어 %%< | ||
+ | \\ | ||
+ | %%< | ||
+ | \\ | ||
+ | CSS를 사용하여 드롭다운 콘텐츠를 올바르게 배치하려면 %%< | ||
+ | \\ | ||
+ | **%%CSS)%%** '' | ||
+ | \\ | ||
+ | '' | ||
+ | '' | ||
+ | **Tip:** 드롭다운 콘텐츠의 너비를 드롭다운 버튼만큼 넓게 하려면, '' | ||
+ | 그리고 작은 화면에서 스크롤을 활성화 하도록 '' | ||
+ | \\ | ||
+ | 보더를 사용하는 대신, CSS '' | ||
+ | \\ | ||
+ | '' | ||
+ | \\ | ||
+ | =====Dropdown Menu===== | ||
+ | 사용자가 목록에서 옵션을 선택하는 드롭다운 메뉴를 만듭니다.\\ | ||
+ | {{: | ||
+ | 하기 예제는 드롭다운 박스 안에 링크를 추가하고 링크에 스타일을 설정하여 스타일링된 드롭다운 버튼에 알맞게 한다는 것 이외에는 이전 예제와 유사합니다.\\ | ||
+ | ====예제==== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | .dropbtn { | ||
+ | background-color: | ||
+ | color: white; | ||
+ | padding: 16px; | ||
+ | font-size: 16px; | ||
+ | border: none; | ||
+ | cursor: pointer; | ||
+ | } | ||
+ | |||
+ | .dropdown { | ||
+ | position: relative; | ||
+ | display: inline-block; | ||
+ | } | ||
+ | |||
+ | .dropdown-content { | ||
+ | /* display: none; */ | ||
+ | position: absolute; | ||
+ | background-color: | ||
+ | min-width: 160px; | ||
+ | box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); | ||
+ | z-index: 1; | ||
+ | } | ||
+ | |||
+ | .dropdown-content a { | ||
+ | color: dodgerblue; | ||
+ | padding: 12px 16px; | ||
+ | text-decoration: | ||
+ | display: block; | ||
+ | } | ||
+ | |||
+ | .dropdown-content a:hover {background-color: | ||
+ | |||
+ | .dropdown: | ||
+ | |||
+ | .dropdown: | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <div class=" | ||
+ | <button class=" | ||
+ | <div class=" | ||
+ | <a href=""> | ||
+ | <a href=""> | ||
+ | <a href=""> | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | \\ | ||
+ | =====Right-aligned Dropdown Content===== | ||
+ | {{: | ||
+ | 드롭다운 메뉴를 왼쪽에서 오른쪽 대신, 오른쪽에서 왼쪽으로 이동하려면 '' | ||
+ | ====예제==== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | .dropbtn { | ||
+ | background-color: | ||
+ | color: white; | ||
+ | padding: 16px; | ||
+ | font-size: 16px; | ||
+ | border: none; | ||
+ | cursor: pointer; | ||
+ | } | ||
+ | |||
+ | .dropdown { | ||
+ | position: relative; | ||
+ | display: inline-block; | ||
+ | } | ||
+ | |||
+ | .dropdown-content { | ||
+ | display: none; | ||
+ | position: absolute; | ||
+ | right: 0; | ||
+ | background-color: | ||
+ | min-width: 160px; | ||
+ | box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); | ||
+ | z-index: 1; | ||
+ | } | ||
+ | |||
+ | .dropdown-content a { | ||
+ | color: black; | ||
+ | padding: 12px 16px; | ||
+ | text-decoration: | ||
+ | display: block; | ||
+ | } | ||
+ | |||
+ | .dropdown-content a:hover {background-color: | ||
+ | |||
+ | .dropdown: | ||
+ | |||
+ | .dropdown: | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <p> | ||
+ | Determine whether the dropdown content should go from left to right or right to left with the left and right properties. | ||
+ | </p> | ||
+ | <div class=" | ||
+ | <button class=" | ||
+ | <div class=" | ||
+ | <a href=""> | ||
+ | <a href=""> | ||
+ | <a href=""> | ||
+ | </ | ||
+ | </ | ||
+ | <div class=" | ||
+ | <button class=" | ||
+ | <div class=" | ||
+ | <a href=""> | ||
+ | <a href=""> | ||
+ | <a href=""> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | ======More Examples====== | ||
+ | =====Dropdown Image===== | ||
+ | 드롭다운 박스 안에 이미지와 다른 콘텐츠를 추가하는 방법\\ | ||
+ | {{: | ||
+ | ====예제==== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | .dropdown { | ||
+ | position: relative; | ||
+ | display: inline-block; | ||
+ | } | ||
+ | |||
+ | .dropdown-content { | ||
+ | display: none; | ||
+ | position: absolute; | ||
+ | background-color: | ||
+ | min-width: 160px; | ||
+ | box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); | ||
+ | z-index: 1; | ||
+ | } | ||
+ | |||
+ | .dropdown: | ||
+ | |||
+ | .desc { | ||
+ | padding: 15px; | ||
+ | text-align: center; | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <div class=" | ||
+ | <img src=" | ||
+ | <div class=" | ||
+ | <img src=" | ||
+ | <div class=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | \\ | ||
+ | =====Dropdown Navbar===== | ||
+ | 네비게이션 바 안에 드롭다운 메뉴를 추가하는 방법\\ | ||
+ | {{: | ||
+ | ====예제==== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | ul { | ||
+ | list-style-type: | ||
+ | margin: 0; | ||
+ | padding: 0; | ||
+ | overflow: hidden; | ||
+ | background-color: | ||
+ | } | ||
+ | |||
+ | li {float: left;} | ||
+ | |||
+ | li a, | ||
+ | .dropbtn { | ||
+ | display: inline-block; | ||
+ | color: white; | ||
+ | text-align: center; | ||
+ | padding: 14px 16px; | ||
+ | text-decoration: | ||
+ | } | ||
+ | |||
+ | li a:hover, .dropdown: | ||
+ | li.dropdown {display: inline-block; | ||
+ | .dropdown-content { | ||
+ | display: none; | ||
+ | position: absolute; | ||
+ | background-color: | ||
+ | min-width: 160px; | ||
+ | box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); | ||
+ | z-index: 1; | ||
+ | } | ||
+ | .dropdown-content a { | ||
+ | color: black; | ||
+ | padding: 12px 16px; | ||
+ | text-decoration: | ||
+ | display: block; | ||
+ | text-align: left; | ||
+ | } | ||
+ | .dropdown-content a:hover {background-color: | ||
+ | .dropdown: | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <ul> | ||
+ | < | ||
+ | < | ||
+ | <li class=" | ||
+ | <a href=" | ||
+ | <div class=" | ||
+ | <a href="#"> | ||
+ | <a href="#"> | ||
+ | <a href="#"> | ||
+ | </ | ||
+ | </li> | ||
+ | </ul> | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
{{tag> | {{tag> |