펼침목록 만들기...
본문
답변 2
아래 코드 사용 시 아래 움짤과 같은 결과를 얻을 수 있으며, 그 이외 내용은 직접 수정 하시길 바랍니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.select {
width: 300px;
margin: 50px auto;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.select_arrow {
margin-left: 10px;
transition: transform 0.3s;
}
.select p {
margin: 0;
padding: 15px;
background-color: #007bff;
color: #fff;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
}
.select p img {
transition: transform 0.3s;
}
.select ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
max-height: 252px;
overflow-y: auto;
}
.select ul li {
border-top: 1px solid #ddd;
}
.select ul li a {
display: block;
padding: 10px 15px;
color: #333;
text-decoration: none;
transition: background-color 0.3s;
}
.select ul li a:hover {
background-color: #f1f1f1;
}
</style>
<script>
$(document).ready(function(){
$('.select p').on('click', function(){
var ul = $(this).next('ul');
var arrow = $(this).find('.select_arrow');
if (ul.is(':visible')) {
ul.slideUp();
arrow.css('transform', 'rotate(0deg)');
} else {
ul.slideDown();
arrow.css('transform', 'rotate(180deg)');
}
});
});
</script>
</head>
<body>
<div class="select">
<p>셀렉트 <span class="select_arrow">▼</span></p>
<ul>
<li><a href="http://www.naver.com" target="_blank">Naver</a></li>
<li><a href="http://www.google.com" target="_blank">Google</a></li>
<li><a href="http://www.daum.net" target="_blank">Daum</a></li>
</ul>
</div>
</body>
</html>
<select name="">
<option vaue="">BUSINESS SITE</option>
</select>
이렇게 select 태그 추가하고 css 를 수정하면 됩니다.
답변을 작성하시기 전에 로그인 해주세요.