반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[code]
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.js"></script>
<style type="text/css">
.paging{color:#555;padding:0;}
.paging li{list-style:none;}
.paging li{line-height:25px; cursor:default; text-align:center; width:25px; height:25px; display:inline-block; font-size: 12px; font-weight:bold; color:#333;}
.paging .pg:hover{cursor:pointer; text-decoration: underline}
.paging .current{color:#FF3636; cursor:default !important; text-decoration:none !important;}
.first, .pre, .next, .last{color:#888 !important;}
.first, .last{letter-spacing:-3px;}
.active{color:#333 !important; cursor:pointer !important;}
</style>
<script type="text/javascript">
window.onload = function() {
var n = 0,
c = 35 , // 전체페이지(35페이지)
w = 27 , //페이지표시 1개의 가로사이즈값
current = 1; // 현재페이지(1페이지)
/* 페이지클릭시 */
$(document).delegate('.pg','click',function(e){
current = parseInt($(this).text());
$('.pg').removeClass('current');$(this).addClass('current'); // 페이지 클릭시 추가되는 클래스(current)
});
/* 맨앞, 앞, 뒤, 맨뒤 버튼 클릭시 */
$(document).delegate('.first, .pre, .next, .last','click',function(e){
var x = Math.floor((parseInt($('.paging').css('width'))-w*4)/w);
if(x > 10){x=10;}
if(n >= 1){
if($(this).is('.first')){current=1;paging();}
if($(this).is('.pre')){current=n-x+1;paging();}
}
if(c > n+x){
if($(this).is('.next')){current=n+x+1;paging();}
if($(this).is('.last')){current=c;paging();}
}
});
/* 맨앞, 앞, 뒤, 맨뒤 버튼 클릭시 */
function paging(){
var page='<li class="first"><<</li><li class="pre"><</li>';
var x = Math.floor((parseInt($('.paging').css('width'))-w*4)/w);
if(x > 10){x=10;}
n = Math.floor(current/x);
if(n == current/x){n = n*x-x;}else{n = n*x}
for(var i=1; i <= x; i++ ){
if(current == i+n){
page += '<li class="pg current">'+(i+n)+'</li>';
}else{
page += '<li class="pg">'+(i+n)+'</li>';}
if(i == x || i == 10 || i+n == c){$('.paging').html(page+'<li class="next">></li><li class="last">>></li>');
if(n > 1){$('.first, .pre').addClass('active');} // 맨앞, 앞 활성화시 추가되는 클래스(active)
if(c > n+x){$('.next, .last').addClass('active');} // 뒤, 맨뒤 버튼 활성화시 추가되는 클래스(active)
break}}
}
paging() //웹페이지 불러올시 반응형페이징 함수 작동
window.onresize = function(){paging()} //브라우저 사이즈 조절시 반응형페이징 함수 작동
}
</script>
<ul class="paging"></ul> <!-- 반응형페이징을 불러올 위치 -->
[/code]
군인신분으로 사이버지식정보방에서 만든거라 보안상 파일업로드가 안되므로 글로 올리는점 양해바랍니다.
http://sir.co.kr/bbs/board.php?bo_table=cm_free&wr_id=1113337
댓글 14개
c = 35 , // 전체페이지(35페이지) 이부분을
c = <?php echo $total_page?> , 로 수정해주시고
current = 1; // 현재페이지(1페이지) 이부분을
current = <?php echo $page ?>; 로 수정해주시면됩니다.
디자인은 알아서^^;
25번줄과 26번줄 구문 사이에 이스크립트를 추가시키면됩니다.
[code]
$(location).attr('href',<?php echo g5_bbs_url ?> + '/board.php?bo_table=' + <?php echo $bo_table ?> + '&page=' + current );
[/code]
근데, 대체 뭘 공부하면 이런 걸 짤 수 있죠? ㅎ
외국사이트돌아다니면서 소스도 한번씩 파헤쳐보고...ㅎ;
제가 반응형웹을 처음 접하게된게 아마 2013년때쯤이었을껍니다.. 그러다가 css로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7630 | 10년 전 | 636 | ||
| 7629 |
|
10년 전 | 2359 | |
| 7628 | 10년 전 | 778 | ||
| 7627 |
|
10년 전 | 1010 | |
| 7626 |
|
10년 전 | 1768 | |
| 7625 | 10년 전 | 677 | ||
| 7624 | 10년 전 | 687 | ||
| 7623 |
|
10년 전 | 3036 | |
| 7622 | 10년 전 | 701 | ||
| 7621 |
leeleeleelee
|
10년 전 | 574 | |
| 7620 | 10년 전 | 531 | ||
| 7619 | 10년 전 | 465 | ||
| 7618 | 10년 전 | 1002 | ||
| 7617 | 10년 전 | 714 | ||
| 7616 | 10년 전 | 619 | ||
| 7615 | 10년 전 | 716 | ||
| 7614 | 10년 전 | 1230 | ||
| 7613 |
|
10년 전 | 2064 | |
| 7612 | 10년 전 | 1126 | ||
| 7611 | 10년 전 | 1391 | ||
| 7610 |
|
10년 전 | 1887 | |
| 7609 |
|
10년 전 | 1304 | |
| 7608 |
mwdkim
|
10년 전 | 1102 | |
| 7607 |
|
10년 전 | 1031 | |
| 7606 |
mwdkim
|
10년 전 | 3906 | |
| 7605 | 10년 전 | 677 | ||
| 7604 | 10년 전 | 1014 | ||
| 7603 | 10년 전 | 1636 | ||
| 7602 |
|
10년 전 | 1051 | |
| 7601 |
AniNest
|
10년 전 | 2768 | |
| 7600 |
port443
|
10년 전 | 1006 | |
| 7599 | 10년 전 | 930 | ||
| 7598 | 10년 전 | 999 | ||
| 7597 | 10년 전 | 4560 | ||
| 7596 |
SeungYeon
|
10년 전 | 878 | |
| 7595 |
untitled
|
10년 전 | 2403 | |
| 7594 |
프로그래머7
|
10년 전 | 1704 | |
| 7593 |
untitled
|
10년 전 | 2346 | |
| 7592 |
untitled
|
10년 전 | 1923 | |
| 7591 |
untitled
|
10년 전 | 2664 | |
| 7590 |
아리마2001
|
10년 전 | 836 | |
| 7589 | 10년 전 | 1093 | ||
| 7588 |
|
10년 전 | 2902 | |
| 7587 | 10년 전 | 1288 | ||
| 7586 | 10년 전 | 650 | ||
| 7585 | 10년 전 | 1667 | ||
| 7584 | 10년 전 | 1399 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1145 | |
| 7582 |
|
10년 전 | 1083 | |
| 7581 | 10년 전 | 1309 | ||
| 7580 | 10년 전 | 962 | ||
| 7579 |
|
10년 전 | 593 | |
| 7578 | 10년 전 | 1407 | ||
| 7577 |
|
10년 전 | 1860 | |
| 7576 | 10년 전 | 1371 | ||
| 7575 |
멋진남자임
|
10년 전 | 1451 | |
| 7574 | 10년 전 | 2097 | ||
| 7573 | 10년 전 | 3225 | ||
| 7572 | 10년 전 | 753 | ||
| 7571 |
|
10년 전 | 774 | |
| 7570 |
|
10년 전 | 1296 | |
| 7569 | 10년 전 | 1530 | ||
| 7568 |
this1mg
|
10년 전 | 1034 | |
| 7567 |
|
10년 전 | 745 | |
| 7566 | 10년 전 | 907 | ||
| 7565 |
Angel하늘
|
10년 전 | 971 | |
| 7564 |
seoldi
|
10년 전 | 1215 | |
| 7563 |
|
10년 전 | 1355 | |
| 7562 |
멋진남자임
|
10년 전 | 2056 | |
| 7561 | 10년 전 | 687 | ||
| 7560 |
leeleeleelee
|
10년 전 | 885 | |
| 7559 | 10년 전 | 5021 | ||
| 7558 |
RinaP
|
10년 전 | 763 | |
| 7557 |
|
10년 전 | 1226 | |
| 7556 | 10년 전 | 1180 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1643 | |
| 7554 | 10년 전 | 1079 | ||
| 7553 |
senseme
|
10년 전 | 1325 | |
| 7552 |
ehdltdoit
|
10년 전 | 1421 | |
| 7551 |
|
10년 전 | 1807 | |
| 7550 |
leeleeleelee
|
10년 전 | 1570 | |
| 7549 | 10년 전 | 2403 | ||
| 7548 | 10년 전 | 1822 | ||
| 7547 |
멋진남자임
|
10년 전 | 1945 | |
| 7546 | 10년 전 | 984 | ||
| 7545 |
ILMare1003
|
10년 전 | 1264 | |
| 7544 |
|
10년 전 | 1224 | |
| 7543 | 10년 전 | 871 | ||
| 7542 | 10년 전 | 644 | ||
| 7541 |
울라라라우
|
10년 전 | 851 | |
| 7540 | 10년 전 | 1587 | ||
| 7539 | 10년 전 | 913 | ||
| 7538 |
|
10년 전 | 1822 | |
| 7537 | 10년 전 | 3599 | ||
| 7536 |
Gaumi
|
10년 전 | 1396 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1251 | |
| 7534 |
senseme
|
10년 전 | 1196 | |
| 7533 | 10년 전 | 1179 | ||
| 7532 | 10년 전 | 841 | ||
| 7531 | 10년 전 | 2032 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기