드롭다운 메뉴 만들기
Javascript 41 [드롭다운 서브메뉴] 순수 자바스크립트 3단계 업그레이드
index_html
<header>
<nav>
<ul class="clearfix">
<li>1st menu
<ul>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>2nd menu
<ul>
<li>2nd menu menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>3rd menu
<ul>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>4th menu
<ul>
<li>2nd menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
</ul>
</nav>
</header>
index_CSS5 tag
* {margin:0; padding:0;}
ul li {list-style:none;}
.clearfix:after{content:'';display:block; clear:both;}
body {background:green; overflow-y:scroll;}
header {
margin-top:20px;
background:linear-gradient(white 50px, rgba(255,255,255,0.5) 50px, rgba(255,255,255,0.5) );
height:50px;
overflow:hidden;
}
nav {width:960px; margin:0 auto;}
nav > ul > li {float:left; line-height:50px; margin-right:40px; position: relative;}
nav > ul > li ul{ width:100%; display: none; position: absolute;}
nav > ul > li ul li{white-space:nowrap;}
index_html&CSS5_시작
<style>
* {margin:0; padding:0;}
ul li {list-style:none;}
.clearfix:after{content:'';display:block; clear:both;}
body {background:green; overflow-y:scroll;}
header {
margin-top:20px;
background:linear-gradient(white 50px, rgba(255,255,255,0.5) 50px, rgba(255,255,255,0.5) );
height:50px;
overflow:hidden;
}
nav {width:960px; margin:0 auto;}
nav > ul > li {float:left; line-height:50px; margin-right:40px; position: relative;}
nav > ul > li ul{ width:100%; display: none; position: absolute;}
nav > ul > li ul li{white-space:nowrap;}
</style>
<header>
<nav>
<ul class="clearfix">
<li>1st menu
<ul>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>2nd menu
<ul>
<li>2nd menu menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>3rd menu
<ul>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>4th menu
<ul>
<li>2nd menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
</ul>
</nav>
</header>
index_html&CSS5_완성
index_html tag
밴드: 네이버 밴드
<!DOCTYPE html> 스핀제공
<html>
<head>
<tiyle></title>
</head>
<body>
<! -- partial: index.partial.html -->
<header>
<nav>
<ul class="clearfix mainmenu">
<li>lst menu
<ul class="submenu">
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</li>
<li>lst menu
<ul class="submenu">
<li>2nd mernu menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
<li>2nd menu</li>
</ul>
</header>
</body>
</html>
네이버 밴드:
HTML tag
HTML tag
첫댓글 https://codepen.io/alikerock/pen/gZoqYw
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default