테스트 사이트 - 개발 중인 베타 버전입니다

탭메뉴

· 16년 전 · 4406 · 4

링크

<t (228)
보통의 경우 탭메뉴는 li 를 사용해 float:left 혹은 float:right; 를 사용해 아래와 같은 형식으로 표현하죠
메뉴1 메뉴2 메뉴3  

이런경우의 소스는 참 많지요.. jquery ui만 둘러봐도 이것저것 많은데.. 만약에

메뉴1 메뉴2 메뉴3 메뉴4

위와 같은 형식으로 100%를 주려면.. px계산하느라 애좀 먹겠지요.. 1px정도 차이가 자꾸날겁니다. 그래서 편하게 테이블로 맹구러버렸습니다..

/*탭메뉴관련 CSS*/
.tab_menu { text-align:center; padding:3px 2px;}
.tab_menu_first_on {
 border:1px solid #cccccc;
 border-bottom:none;
 background-color:#ffffff;
 cursor:normal;
}
.tab_menu_first_off {
 border:1px solid #cccccc;
 background-color:#f1f1f1;
 cursor:pointer;
}
.tab_menu_other_on {
 border-top :1px solid #cccccc;
 border-right:1px solid #cccccc;
 background-color:#ffffff;
 cursor:normal;
}
.tab_menu_other_off {
 border:1px solid #cccccc;
 border-left:none;
 background-color:#f1f1f1;
 cursor:pointer;
}
.tab_content { border:1px solid #cccccc; border-top:none;}
.tab_content_on {display:block;}
.tab_content_off {display:none;}
.tab_button_more {clear:both; padding-top:5px; text-align:right;}

/*탭메뉴관련 script*/
 $(document).ready(function(){
  $(".tab_menu").click(function(){
   var now_menu = $(this).attr('id');
   var now_cont = now_menu.replace('tab_menu_','tab_cont_');
   var id = now_menu.substring(0, now_menu.length - 3);
   var idx = $('#'+id).find('.tab_menu').index(this);

   if(idx == 0){
    $('#'+id).find('.tab_menu:gt(0)').removeClass('tab_menu_other_on').addClass('tab_menu_other_off');
    $('#'+id).find('.tab_menu:eq(0)').removeClass('tab_menu_first_off').addClass('tab_menu_first_on');
   } else {
    $('#'+id).find('.tab_menu:eq(0)').removeClass('tab_menu_first_on').addClass('tab_menu_first_off');
    $('#'+id).find('.tab_menu:gt(0)').removeClass('tab_menu_other_on').addClass('tab_menu_other_off');
    $('#'+now_menu).removeClass('tab_menu_other_off').addClass('tab_menu_other_on');
   }

   $('#'+id).find('.tab_content').removeClass('tab_content_on').addClass('tab_content_off');
   $('#'+now_cont).removeClass('tab_content_off').addClass('tab_content_on');
  });
 });
/*
탭메뉴관련 html  앞의 test를 다른걸로 바꾸시면 되며
tab1_tab_menu, tab2_tab_menu등으로 여러개를 동시에 사용가능합니다.
또 중요한건 큰테이블의 아이디는 'xxxxxx_tab_menu'
탭메뉴들의 아이디는 'xxxxxx_tab_menu_01~99' 01~99는 영문이든 숫자든 상관없으며 2자리로 구성해주세요..
탭내용들의 아이디는 'xxxxxx_tab_cont_01~99' 01~99는 영문이든 숫자든 상관없으며 2자리로 구성해주세요.. 단 맵메뉴의 아이디 끝 두자리와 일치해야합니다.
*/
 <table border=0 width=100% cellpadding=0 cellspacing=0 id='test_tab_menu'>
 <tr>
  <td width=25% id='test_tab_menu_01' class='tab_menu tab_menu_first_on'>내용1</td>
  <td width=25% id='test_tab_menu_02' class='tab_menu tab_menu_other_off'>내용2</td>
  <td width=25% id='test_tab_menu_03' class='tab_menu tab_menu_other_off'>내용3</td>
  <td width=25% id='test_tab_menu_04' class='tab_menu tab_menu_other_off'>내용4</td>
 </tr>
 <tr>
  <td colspan=4>
  <table border=0 width=100% cellpadding=0 cellspacing=0 id='test_tab_cont_01' class='tab_content tab_content_on'>
  <tr>
   <td style='padding:10px 5px;'>내용1 내용1</td>
  </tr>
  </table>
  <table border=0 width=100% cellpadding=0 cellspacing=0 id='test_tab_cont_02' class='tab_content tab_content_off'>
  <tr>
   <td style='padding:10px 5px;'>내용2 내용2</td>
  </tr>
  </table>
  <table border=0 width=100% cellpadding=0 cellspacing=0 id='test_tab_cont_03' class='tab_content tab_content_off'>
  <tr>
   <td style='padding:10px 5px;'>내용2 내용3</td>
  </tr>
  </table>
  <table border=0 width=100% cellpadding=0 cellspacing=0 id='test_tab_cont_04' class='tab_content tab_content_off'>
  <tr>
   <td style='padding:10px 5px;'>내용2 내용4</td>
  </tr>
  </table>
  </td>
 </tr>
 </table>

혹시 div코딩으로 처리가능하신분은 올려주세요.. 하다하다 안되서
테이블 코딩해버린겁니다 ㅎㅎ;;
css코딩이 허접한지라.. ㅠ.ㅠ

[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 4개

float:left로 쭉 정렬해서 하면 안 될까요?ㅎㅎ


<style>
.tab_menu {float:left;}
</style>

<div id='test_tab_menu'>
<div id='test_tab_menu_01' class='tab_menu tab_menu_first_on'>내용1</div>
<div id='test_tab_menu_02' class='tab_menu tab_menu_first_off'>내용2</div>
<div id='test_tab_menu_03' class='tab_menu tab_menu_first_off'>내용3</div>
<div id='test_tab_menu_04' class='tab_menu tab_menu_first_off'>내용4</div>
<div>
탭메뉴가 뭔가요?

혹시 상단에 있는 홈/로그인/로그아웃/회원가입-----------이 메뉴 인가요?
13년 전
12년 전
ㅋㅋㅋ

게시글 목록

번호 제목
20215
20214
20213
20212
28362
20211
20210
20209
20208
20207
20206
20205
20204
20203
20202
20201
20200
20199
JavaScript 계산기
20198
20197
20196
20195
20194
20193
20192
20191
20190
20189
20188
28361
20187
20186
20185
20184
20183
20182
20181
20180
20179
20177
8183
31027
8181
20176
20175
20174
20173
20172
20171
20170
20169
20168
20156
20154
20153
20152
8177
20151
20149
20148
20147
20146
20145
20144
20143
20142
20141
20140
20139
20137
20135
20134
20133
20129
20128
20126
8172
20123
20122
20121
20117
20116
20115
20114
20113
20112
20111
20110
20109
20108
20107
20106
20104
20103
20102
20101
31024
20100
20099
20098