묻고답하기
마우스 갖다대면 나오는 2차메뉴 위치 질문
2009.03.15 15:35
<ul id="gnb">
<!-- main_menu 1차 시작 -->
{@ $idx = 1 }
<!--@foreach($main_menu->list as $key => $val)--><!--@if($val['text'])-->
<!--@if($val['selected'])-->
{@ $menu_1st = $val }
<!--@end-->
<li onMouseOver="menu({$idx});" <!--@if($val['selected'])-->class="on"<!--@end-->><a href="{$val['href']}" <!--@if($val['open_window']=='Y')-->onclick="window.open(this.href);return false;"<!--@end-->>{$val['text']}</a></li>
<!--@end-->
{@$idx++}
<!--@end-->
<!-- main_menu 1차 끝 -->
</ul>
<script language="javascript1.2">
var menuLen={$idx-1};
</script>
<!--히든 레이어 메뉴-->
<!-- main_menu 1차 시작 -->
{@ $idx = 1 }
<!--@foreach($main_menu->list as $key => $val)--><!--@if($val['text'])-->
<!--2차메뉴-->
<div class="subMenu" id="subMenu_{$idx}" style="<!--@if($val['selected'])-->display:block;<!--@else-->display:none;<!--@end-->">
<!--@foreach($val['list'] as $key1 => $val1)--><!--@if($val1['text'])-->
<!--@if($val1['selected'])--><!--@end-->
<a id="lnb1" href="{$val1['href']}" <!--@if($val1['open_window']=='Y')-->onclick="window.open(this.href);return false;"<!--@end-->>{$val1['text']}</a>
<!--@end-->
<!--@end-->
</div>
<!--@end-->
{@$idx++}
<!--@end-->
<!-- main_menu 1차 끝 -->
자바스크립트
// Hide And Show Toggle
var cc=0
function hideShow(id) {
if (cc==0) {
cc=1
document.getElementById(id).style.display="none";
} else {
cc=0
document.getElementById(id).style.display="block";
}
}
// Show And Hide Toggle
var cc=0
function showHide(id) {
if (cc==0) {
cc=1
document.getElementById(id).style.display="block";
} else {
cc=0
document.getElementById(id).style.display="none";
}
}
// Local Navigation Toggle
function lnbToggle(id) {
for(num=1; num<=3; num++) document.getElementById('D3MG'+num).style.display='none'; //D4MG1~D4MG3 까지 숨긴 다음
document.getElementById(id).style.display='block'; //해당 ID만 보임
}
// IS
function chkIsKind(key, value) {
showHide('selectOrder');
xGetElementById('search_target'+key).checked = true;
xInnerHtml('search_target_label', value);
}
function menu(idx){
for (i=1;i<=menuLen;i++){
eval("document.getElementById('subMenu_"+i+"').style.display='none'");
}
eval("document.getElementById('subMenu_"+ idx +"').style.display='block'");
}
CSS
@charset "utf-8";
/*
NHN UIT Lab. WebStandardization Team (http://html.nhndesign.com/)
Jeong, Chan Myeong 070601~070630
*/
/* Black Skin - Start */
#selectLang { margin:0; padding:0; }
#gnb { margin:30; padding:0; }
#lnb { margin:0; padding:0; }
#lnb ul { margin:0; padding:0; }
/* Site Layout - Body Wrap */
body { background:#000;}
#bodyWrap { position:relative; width:980px; margin:0 auto; padding:0em 0 0 0;}
/* Site Layout - Header */
#header { position:relative; width:965px; height:90px; background:url(../images/black/bgHeader.gif) no-repeat right top; margin-bottom:10px; z-index:99;}
#header h1 { position:absolute; top:0px; left:30px;}
#language { position:absolute; top:18px; right:19px; z-index:100;}
#language strong { color:#ffffff; font:.75em Tahoma; margin-right:3px;}
#language a img { vertical-align:-5px;}
#language ul { position:absolute; top:15px; right:0px; display:none; border:1px solid #282827; background:#3d3d3d;}
#language ul li { list-style:none; }
#language ul li a { display:block; width:61px; padding:3px 8px; font:9px Tahoma; color:#cbcbcb; text-decoration:none;}
#language ul li a:hover { background:#373736;}
#it_search_form { position:absolute; top:50px; right:15px;}
#it_search_form .input { border:1px solid #bc4032; height:17px; width:120px; color:#888888; font-size:.9em;}
#it_search_form .submit_button { width:1px; height:1px; visibility:hidden; }
#gnb { position:absolute; top:25px; left:160px; height:38px; overflow:hidden; white-space:nowrap; margin-bottom:10px;}
#gnb li { list-style:none; float:left; background:url(../images/black/bgGnbVr.gif) no-repeat left center; padding-left:2px; position:relative; left:-2px; white-space:nowrap;}
#gnb li a { display:block; float:left; padding:0px 15px 0 15px; height:25px; color:#a6a6a6; white-space:nowrap; text-decoration:none; }
#gnb li a:hover,
#gnb li a:focus { color:#ffffff;}
#gnb li.on a { font-weight:bold; color:#ffffff; background:url(../images/black/bgGnbOn.gif) no-repeat center top;}
#isSearch { position:absolute; top:48px; right:15px; width:214px; text-align:right;}
#isSearch .searchOrder { display:none;}
#isSearch .checked { position:absolute; left:0; top:0; text-align:left; display:block; padding:5px 0 0 5px; width:64px; height:14px; background:url(../images/black/bgSearchTerm.gif) no-repeat; font:11px "돋움", Dotum, "굴림", Gulim, AppleGothic, Sans-serif; color:#ffffff; line-height:normal;}
#isSearch ul { display:none; position:absolute; left:0; top:18px; padding:2px 0 3px 0; text-align:left; border:1px solid #6e8081; background:#385153;}
#isSearch ul li { width:67px; height:18px; list-style:none;}
#isSearch ul li input { display:none;}
#isSearch ul li label { display:block; padding:4px 0 0 4px; width:63px; height:15px; font:11px "돋움", Dotum, "굴림", Gulim, AppleGothic, Sans-serif; color:#ffffff;}
#isSearch ul li label.on { background:#2f4345; }
#isSearch ul li label:hover,
#isSearch ul li label:focus { background:#2f4345;}
#isSearch .inputText { vertical-align:middle; position:relative; top:0; _top:-1px; left:1px; padding:3px 3px 1px 3px; width:94px; height:13px; color:#ffffff; border:1px solid #8E8E8D; background-color:#857C79; }
#isSearch .inputText:hover,
#isSearch .inputText:focus { border:1px solid #B0B0AF; background-color:#A9A4A3; }
*:first-child+html #isSearch .inputText { position:relative; top:-1px;}
#isSearch .submit { vertical-align:middle; _position:relative; _top:-1px;}
*:first-child+html #isSearch .submit { position:relative; top:-1px;}
/* Site Layout - Content Body */
#contentBody { position:relative; width:980px; padding-bottom:30px; overflow:hidden; background:url(../images/black/bgContentBody.gif) repeat-y left top; border-bottom:1px solid #FFFFFF;}
/* Site Layout - Column Left */
#columnLeft { position:relative; width:201px; float:left;}
#columnLeft .mask { width:201px; height:5px; background:#3d3d3d; display:block;}
#lnb { border-top:1px solid #515151; padding:4px 5px; width:190px;}
#lnb li { list-style:none; padding-bottom:4px;}
#lnb li a { padding:6px 5px 6px 13px; width:170px; display:block; border:1px solid #565655; background:url(../images/black/bgLnbOff.gif) repeat-x; color:#c2c2c2; position:relative; z-index:99; text-decoration:none;}
#lnb li a:hover,
#lnb li a:focus { color:#ffffff; background:#e61700; border:1px solid #870000;}
#lnb li.on a { color:#ffffff; background:#e61700; border:1px solid #870000;}
#lnb li.on a:hover,
#lnb li.on a:focus { font-weight:bold;}
#lnb li ul { display:block; position:relative; width:184px; padding:0 3px; position:relative; border-top:1px solid #3d3d3d; overflow:hidden;}
#lnb li.on ul { display:block;}
#lnb li ul li { padding:0; border-top:1px solid #474747; position:relative; top:-1px;}
#lnb li ul li a { padding:6px 5px 6px 10px; width:169px; color:#818181 !important; border:none; background:none !important; border:none !important;}
#lnb li ul li a:hover,
#lnb li ul li a:focus { font-weight:normal !important; color:#de4332 !important;}
#lnb li.on ul li.on a { color:#870000 !important; font-weight:bold !important; background:url(../images/black/bulletLnb.gif) no-repeat 175px center !important;}
/* Site Layout - Column Right */
#columnRight { width:770px; float:right; overflow:hidden;}
#visualArea { width:770px; height:200px; background:#151514; margin-bottom:2.5em; position:relative; left:-15px; margin-right:-15px; color:#999999;}
#content { width:100%; overflow:hidden;}
/* Site Layout - Footer */
#footer { margin:0; padding:0; border-top:3px solid #424242; text-align:center; padding:2em 0 4em; clear:both;}
#footer li { display:inline; padding:0 .6em 0 1em; background:url(../images/black/vrType1.gif) no-repeat left center;}
#footer li.first-child { background:none;}
#footer li a { color:#818181; font:.9em "돋움", Dotum, "굴림", Gulim, AppleGothic, Sans-serif;}
#footer li address { display:inline; }
.subMenu{position:absolute; left:200px; top:50px; background-color:FFFFFF;width:750px;height:24px;}
#lnb1{text-decoration:none;color:#FFFFFF;padding-left:10px; line-height:2em; position:relative;white-space:nowrap; }
#lnb1:hover,focus {color:#FFFFFF}
이렇게 설정되있구요. 아무이상없이 작동 잘 합니다.
다만 마우스 대면 메뉴 바로 아래가 아닌 항상 고정된위치에서만
출력됩니다 예를들어서
홈 게시판 자료실
2차메뉴
이렇게 있으면 자료실에 마우스를 갖다대면 2차메뉴라고 써진곳에 2차메뉴가 뜹니다.
각 메뉴 바로 아래에 출력되게 하려면 어떻게 수정하여야 할까요?
홈 게시판 자료실
2차메뉴 이런식
위치가 고정이 아니라 각 메뉴별 위치 설정을 하고 싶습니다.
도와주세요~