자바스크립으로 플래쉬 메뉴처럼

톡박에 한번 올렸던 소스인데 조금 다듬어서 올립니다.
적절히 수정&가공하시면 멋진 메뉴가 나올거에요~

<html>
 <head>
  <title>Menu</title>
 </head>
<script>
var delay = 3;            // 메뉴 스피드(낮을수록 빠름)
var m_length = 20;    // 메뉴 간격
var sel_l_length = 30;    // 선택한 메뉴와 이전 메뉴 간격
var sel_r_length = 60;    // 선택한 메뉴와 다음 메뉴 간격


var m_sel = 0;            // 메뉴 선택 상태
var m_max = 0;        // 메인메뉴 갯수
var sm_alpha = 0;    // 서브메뉴 투명도
var id = new Array();    // 메인메뉴 ID
var sid = new Array();    // 서브메뉴 ID
var m_top = 0;                // 메인메뉴 y 위치
function on_load(){
    while(document.getElementById("menu"+(m_max+1)) != null){
        m_max++;
        id[m_max] = document.getElementById("menu"+m_max);
        sid[m_max] = document.getElementById("smenu"+m_max);
    };
    m_top = id[1].offsetTop;
    m_act();
}
function m_over(m){
    m_sel = m;
    for(i=1;i<=m_max;i++){
        if(sid[i] != null){
            if(m_sel == i){
                id[i].style.fontWeight = 'bold';
                sid[i].style.display = "";
                sm_alpha = 0;
                if ((navigator.appName.indexOf('Microsoft')+1)) {
                    sid[i].filters.alpha.opacity = sm_alpha;
                }else{
                    sid[i].style.opacity = (sm_alpha/100);
                }
                sid[i].style.top = id[i].offsetTop + id[i].offsetHeight + 40;
            }else{
                id[i].style.fontWeight = '';
                sid[i].style.display = "none";
            }
        }
    }
}
function m_act(){
    var goy = 0;
    for(i=1;i<=m_max;i++){

        // 메인메뉴 좌우 이동
        if(i>1)
            temp = id[i-1].offsetWidth + id[i-1].offsetLeft;
        if(i==1){
            gox=id[i].offsetLeft;
        }else if(m_sel == i){
            gox =  temp + sel_l_length;
        }else if(m_sel+1 == i){
            gox =temp + sel_r_length;
        }else{
            gox = temp + m_length;
        }
        id[i].style.left = Math.ceil(id[i].offsetLeft - (id[i].offsetLeft - (gox))/delay)+"px";

        // 메인메뉴 상하 이동
        if(m_sel == i){
            id[i].style.top = Math.ceil(id[i].offsetTop - (id[i].offsetTop - (m_top + 7))/delay)+"px";
        }else if(m_sel!=0){
            id[i].style.top = Math.ceil(id[i].offsetTop - (id[i].offsetTop - (m_top - 5))/delay)+"px";
        }

        // 서브메뉴
        if(m_sel == i && sid[i] != null){
            // 서브메뉴 투명도
            if(sm_alpha < 100){
                sm_alpha += 5;
                if ((navigator.appName.indexOf('Microsoft')+1)) {
                    sid[i].filters.alpha.opacity = sm_alpha;
                }else{
                    sid[i].style.opacity = (sm_alpha/100);
                }
            }
            // 서브메뉴 아래서부터 위로 나타남
            goy = id[i].offsetTop + id[i].offsetHeight;
            sid[i].style.top = (sid[i].offsetTop - (sid[i].offsetTop - goy)/delay)+"px";
        }
    }
    setTimeout('m_act()',20);
}

</script>
<style>
.sm_a{color: #666666; text-decoration:none; padding:0px 3px 0px 2px}
.sm_a:hover {color: #FFFFFF; text-decoration:none; background:#666666; padding:0px 3px 0px 2px}
div{font-family:verdana; font-size:10px; letter-spacing:-1px}
.smenu{top:50px; position:absolute; filter:alpha(opacity=0); color:#DDDDDD}
.mmenu{top:30px; position:absolute; cursor:pointer; padding-right:2px; color:#666666}
</style>
<body onload='on_load()'>
    <div class=mmenu style='left:200px;' id=menu1 onClick='m_over(1)'>
    ABOUT US<br>
    </div>
    <div id='smenu1' class=smenu style='left:200px; display:none'><a href='' class=sm_a>menu1</a> | <a href='' class=sm_a>menu2</a> | <a href='' class=sm_a>menu3</a></div>
    <div class=mmenu style='left:280px;' id=menu2 onClick='m_over(2)'>
    PRODUCT<br>
    </div>
    <div id='smenu2' class=smenu style='left:250px; display:none'><a href='' class=sm_a>menu4</a> | <a href='' class=sm_a>menu5</a> | <a href='' class=sm_a>menu6</a></div>
    <div class=mmenu style='left:360px;' id=menu3 onClick='m_over(3)'>
    STORY<br>
    </div>
    <div id='smenu3' class=smenu style='left:310px; display:none'><a href='' class=sm_a>menu7</a> | <a href='' class=sm_a>menu8</a> | <a href='' class=sm_a>menu9</a></div>
</body>
</html>
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|

댓글 10개

우왓 ~ 고맙습니다. 지금 혼자 끙끙대던 건데^^
우아~이거 최곤데요
와우 멋진데요 감사 합니다
정말 좋네요 감사합니다.
블루비 자료와 같은데..요?
플레시메뉴처럼
감사합니다^^

멋지네요 - ㅎㅎㅎ
좋네요!! 추천한방^^
와,이거 정말 필요했었는데..감사합니다 ^^
정말이지 자바스크립트의 무한한가능성을 다시 한번 되새겨봅니다.
정말 대단하시네요~ 감탄했습니다.
정말 수고많으셨습니다. 새해 복 많이받으세요^^
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

태그 필터 (최대 3개) 전체 개발자 소스 기타 mysql 팁자료실 javascript php linux flash 정규표현식 jquery node.js mobile 웹서버 os 프로그램 강좌 썸네일 이미지관련 도로명주소 그누보드5 기획자 견적서 계약서 기획서 마케팅 제안서 seo 통계 서식 통계자료 퍼블리셔 html css 반응형 웹접근성 퍼블리싱 표준화 반응형웹 홈페이지기초 부트스트랩 angularjs 포럼 스크린리더 센스리더 개발자톡 개발자팁 퍼블리셔톡 퍼블리셔팁 기획자톡 기획자팁 프로그램강좌 퍼블리싱강좌
+
제목 글쓴이 날짜 조회
18년 전 조회 3,519
18년 전 조회 1,706
18년 전 조회 3,482
18년 전 조회 2,055
18년 전 조회 5,321
18년 전 조회 2,184
18년 전 조회 2,368
18년 전 조회 1,763
18년 전 조회 2,167
18년 전 조회 3,688
18년 전 조회 1,543
18년 전 조회 1,777
18년 전 조회 4,354
18년 전 조회 3,739
18년 전 조회 3,304
18년 전 조회 3,409
18년 전 조회 3,904
18년 전 조회 4,366
18년 전 조회 4,289
18년 전 조회 2,740
18년 전 조회 2,361
18년 전 조회 3,289
18년 전 조회 3,210
18년 전 조회 3,362
18년 전 조회 3,293
18년 전 조회 4,957
18년 전 조회 5,246
18년 전 조회 3,442
18년 전 조회 2,749
18년 전 조회 2,990
18년 전 조회 2,309
18년 전 조회 2,122
18년 전 조회 2,078
18년 전 조회 3,105
18년 전 조회 2,391
18년 전 조회 2,410
18년 전 조회 2,084
18년 전 조회 2,461
18년 전 조회 3,197
18년 전 조회 4,131
18년 전 조회 3,409
18년 전 조회 2,048
18년 전 조회 1,986
18년 전 조회 2,899
18년 전 조회 1,694
18년 전 조회 2,053
18년 전 조회 2,334
18년 전 조회 2,206
18년 전 조회 2,306
18년 전 조회 4,060
18년 전 조회 1,819
18년 전 조회 4,421
18년 전 조회 2,956
18년 전 조회 2,263
18년 전 조회 3,301
18년 전 조회 2,932
18년 전 조회 2,868
18년 전 조회 5,661
18년 전 조회 2,328
18년 전 조회 3,449
18년 전 조회 3,361
18년 전 조회 3,747
18년 전 조회 3,297
18년 전 조회 2,478
18년 전 조회 2,130
18년 전 조회 2,581
18년 전 조회 6,148
18년 전 조회 2,771
18년 전 조회 4,568
18년 전 조회 2,069
18년 전 조회 1만
18년 전 조회 2,518
18년 전 조회 1,579
18년 전 조회 3,022
18년 전 조회 2,963
18년 전 조회 2,852
18년 전 조회 2,167
18년 전 조회 2,357
18년 전 조회 2,903
18년 전 조회 2,994
18년 전 조회 4,166
18년 전 조회 6,144
18년 전 조회 2,085
18년 전 조회 2,218
18년 전 조회 1,925
18년 전 조회 1,683
18년 전 조회 2,661
18년 전 조회 1,711
18년 전 조회 1,589
18년 전 조회 4,769
18년 전 조회 1,815
18년 전 조회 1,873
18년 전 조회 1,878
18년 전 조회 1,999
18년 전 조회 3,653
18년 전 조회 1,681
18년 전 조회 1,559
18년 전 조회 1,388
18년 전 조회 1,889
18년 전 조회 1,934