샘플이미지
#html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Menu</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav>
<ul class="menu">
<li><a href="#">Home</a></li>
<li>
<a href="#">Services</a>
<ul class="dropdown">
<li><a href="#">Web Development</a></li>
<li><a href="#">SEO</a></li>
<li><a href="#">Marketing</a></li>
</ul>
</li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="scripts.js"></script>
</body>
</html>
#css(styles.css)
body {
font-family: Arial, sans-serif;
}
nav {
background-color: #333;
overflow: hidden;
}
.menu {
list-style-type: none;
margin: 0;
padding: 0;
}
.menu > li {
float: left;
}
.menu > li > a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.menu > li > a:hover {
background-color: #111;
}
.dropdown {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
z-index: 1;
list-style-type: none;
padding: 0;
}
.dropdown > li > a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown > li > a:hover {
background-color: #111;
}
.menu > li:hover .dropdown {
display: block;
}
#jQuery(scripts.js)
$(document).ready(function() {
$('.menu > li').hover(
function() {
$(this).find('.dropdown').stop(true, true).slideDown(200);
},
function() {
$(this).find('.dropdown').stop(true, true).slideUp(200);
}
);
});
반응형
'프로그램 > 메뉴(Menu)' 카테고리의 다른 글
심플한 웹사이트 세로 메뉴 만들기(소스 포함) (0) | 2024.08.06 |
---|---|
React Slide In Menu (0) | 2024.02.19 |
React Stripe Menu (0) | 2024.02.19 |
React.js dropdown menu (0) | 2024.02.19 |
Basic Dropdown with React Hooks (0) | 2024.02.19 |
댓글