-
롤오버 (2) 개인적으로 이거 괜찮음JavaScript 2014. 3. 19. 21:23반응형
<!DOCTYPE html>
<html>
<head>
<title>메뉴예제</title>
<!-- 메뉴 롤오버 스크립트 -->
<script type="text/javascript">
function menu_over(a) {
var preName = 'menu';
var subName = 'sub';
for(var i = 1 ; i < 9 ; i++){
getObject(preName + i).className = 'menu_level_1' + (i == parseInt(a) ? '_over' : '');
getObject(preName + i + subName).className = 'menu_level_2' + (i == parseInt(a) ? '_over' : '');
}
}
function getObject(objName){
return document.getElementById(objName);
}
<!-- // 메뉴 롤오버 스크립트 -->
</script>
<style>
@font-face {font-family:NanumGothic; src:url(img/NanumGothic.eot);}
body,p,h1,h2,h3,h4,h5,h6,ul,ol,li,dl,dt,dd,table,th,td,form,fieldset,legend,input,textarea,button,select{margin:0;padding:0}
body,input,textarea,select,button,table{font-family:'돋움',Dotum,AppleGothic,sans-serif;font-size:12px}
img,fieldset{border:0}
ul,ol{list-style:none}
em,address{font-style:normal}
a{text-decoration:none}
a:hover,a:active,a:focus{text-decoration:underline}
.lnb1 {margin:0 auto;
background:#1F68CA; border:1px solid #1F68CA; width:1000px; height:35px; text-align:left; border-radius: 5px 5px 0 0;
background:#850909 -webkit-gradient(linear, 0% 0%, 0% 100%,from(#5DA0FA), to(#1F68CA));
background:#850909 -moz-linear-gradient(top, #5DA0FA, #1F68CA);
filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#5DA0FA,endColorStr=#1F68CA);
}
.lnb2{margin:0 auto; background:#efefef; border:1px solid #cccccc; width:1000px; height:33px; text-align:left; border-radius: 0 0 5px 5px;}
.menu_level_1 {color:white; font-family:NanumGothic; Font-weight:500; float:left; padding:10px 15px 0 15px; cursor:pointer;}
.menu_level_1_over {color:black; font-family:NanumGothic; Font-weight:500; float:left; background:white; border-radius: 5px 5px 0 0; margin:5px 5px 0 5px; padding:10px 15px 7px 15px; cursor:pointer;}
.menu_level_2 {display:none;}
.menu_level_2_over {display:block;}
.menu_level_2_over div {cursor:pointer; padding:10px; font-family:NanumGothic; padding:10px; cursor:pointer; float:left;}
.menu_level_2_over div:hover {display:block; Font-weight:bold; cursor:pointer;}
</style>
</head>
<body>
<br />
<br />
<br />
<div class="lnb1" style="clear:both;">
<div id="menu1" class="menu_level_1_over" onmouseover="menu_over('1')">Menu1</div>
<div id="menu2" class="menu_level_1" onmouseover="menu_over('2')">메뉴2</div>
<div id="menu3" class="menu_level_1" onmouseover="menu_over('3')">메뉴3</div>
<div id="menu4" class="menu_level_1" onmouseover="menu_over('4')">메뉴4</div>
<div id="menu5" class="menu_level_1" onmouseover="menu_over('5')">메뉴5</div>
<div id="menu6" class="menu_level_1" onmouseover="menu_over('6')">메뉴6</div>
<div id="menu7" class="menu_level_1" onmouseover="menu_over('7')">메뉴7</div>
<div id="menu8" class="menu_level_1" onmouseover="menu_over('8')">메뉴8</div>
</div>
<div class="lnb2" style="clear:both;">
<div id="menu1sub" class="menu_level_2_over">
<div>메뉴1_서브메뉴1</div>
<div>서브메뉴2</div>
<div>서브메뉴3</div>
<div>서브메뉴4</div>
<div>서브메뉴5</div>
<div>서브메뉴6</div>
<div>서브메뉴7</div>
<div>서브메뉴8</div>
</div>
<div id="menu2sub" class="menu_level_2">
<div>메뉴2_서브메뉴1</div>
<div>서브메뉴2</div>
<div>서브메뉴3</div>
<div>서브메뉴4</div>
<div>서브메뉴5</div>
<div>서브메뉴6</div>
<div>서브메뉴7</div>
<div>서브메뉴8</div>
</div>
<div id="menu3sub" class="menu_level_2">
<div>메뉴3_서브메뉴1</div>
<div>서브메뉴2</div>
<div>서브메뉴3</div>
<div>서브메뉴4</div>
<div>서브메뉴5</div>
<div>서브메뉴6</div>
<div>서브메뉴7</div>
<div>서브메뉴8</div>
</div>
<div id="menu4sub" class="menu_level_2">
<div>메뉴4_서브메뉴1</div>
<div>서브메뉴2</div>
<div>서브메뉴3</div>
<div>서브메뉴4</div>
<div>서브메뉴5</div>
<div>서브메뉴6</div>
<div>서브메뉴7</div>
<div>서브메뉴8</div>
</div>
<div id="menu5sub" class="menu_level_2">
<div>메뉴5_서브메뉴1</div>
<div>서브메뉴2</div>
<div>서브메뉴3</div>
<div>서브메뉴4</div>
<div>서브메뉴5</div>
<div>서브메뉴6</div>
<div>서브메뉴7</div>
<div>서브메뉴8</div>
반응형'JavaScript' 카테고리의 다른 글
오른쪽 마우스 사용 못하게 하기 (0) 2014.03.21 placeholder()와 같은 기능!!! (0) 2014.03.20 롤오버시 서브메뉴가 나타나는 기본 스크립트 (0) 2014.03.19 새로고침(F5) 금지 하는 자바스크립트 (0) 2014.03.19 유효성 검사 (2) 2014.03.17