250x250
반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- git pull
- https
- root
- Xdebug
- Certbot
- crontab
- vscode
- MariaDB
- Fail2ban
- 구글 클라우드
- html
- LetsEncrypt
- wordpress
- php
- new user
- front page
- non-www
- SSL
- Liniux
- launch.json
- child theme
- DOM Parser
- Mac
- home page
- centos
- Google Cloud
- Apache
- Linux
- CentOS7
- mysql
Archives
- Today
- Total
between 0 and 1
[DropDown UI] UL - LI 구조를 Select (Drop Down) UI 로 만들기 본문
Software Development Engineering/HTML & CSS
[DropDown UI] UL - LI 구조를 Select (Drop Down) UI 로 만들기
devxpert.yoon 2020. 12. 1. 01:39728x90
반응형
HTML
<ul class="list-unstyled">
<li class="init">[SELECT]</li>
<li data-value="value 1">Option 1</li>
<li data-value="value 2">Option 2</li>
<li data-value="value 3">Option 3</li>
</ul>
CSS
body{
padding:30px;
}
ul {
height: 30px;
width: 150px;
border: 1px #000 solid;
}
ul li { padding: 5px 10px; z-index: 2; }
ul li:not(.init) { float: left; width: 130px; display: none; background: #ddd; }
ul li:not(.init):hover, ul li.selected:not(.init) { background: #09f; }
li.init { cursor: pointer; }
a#submit { z-index: 1; }
JS
$("ul").on("click", ".init", function() {
$(this).closest("ul").children('li:not(.init)').toggle();
});
var allOptions = $("ul").children('li:not(.init)');
$("ul").on("click", "li:not(.init)", function() {
allOptions.removeClass('selected');
$(this).addClass('selected');
$("ul").children('.init').html($(this).html());
allOptions.toggle();
});
728x90
반응형
'Software Development Engineering > HTML & CSS' 카테고리의 다른 글
배경이미지에 Fading 효과 주기 (0) | 2019.04.12 |
---|