반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6630 |
차가운바람
|
12년 전 | 1168 | |
| 6629 | 12년 전 | 1166 | ||
| 6628 |
put777
|
12년 전 | 650 | |
| 6627 |
|
12년 전 | 703 | |
| 6626 | 12년 전 | 1618 | ||
| 6625 |
|
12년 전 | 727 | |
| 6624 |
미켈란젤로의왼손
|
12년 전 | 493 | |
| 6623 |
|
12년 전 | 1052 | |
| 6622 | 12년 전 | 1402 | ||
| 6621 |
차가운바람
|
12년 전 | 641 | |
| 6620 | 12년 전 | 743 | ||
| 6619 |
|
12년 전 | 979 | |
| 6618 | 12년 전 | 1749 | ||
| 6617 | 12년 전 | 645 | ||
| 6616 |
차가운바람
|
12년 전 | 903 | |
| 6615 | 12년 전 | 2858 | ||
| 6614 | 12년 전 | 622 | ||
| 6613 |
강명구베드로
|
12년 전 | 534 | |
| 6612 |
|
12년 전 | 429 | |
| 6611 | 12년 전 | 1213 | ||
| 6610 | 12년 전 | 1034 | ||
| 6609 | 12년 전 | 3685 | ||
| 6608 |
|
12년 전 | 834 | |
| 6607 | 12년 전 | 698 | ||
| 6606 | 12년 전 | 568 | ||
| 6605 | 12년 전 | 459 | ||
| 6604 | 12년 전 | 978 | ||
| 6603 |
geektoo
|
12년 전 | 709 | |
| 6602 | 12년 전 | 845 | ||
| 6601 | 12년 전 | 374 | ||
| 6600 | 12년 전 | 419 | ||
| 6599 | 12년 전 | 574 | ||
| 6598 | 12년 전 | 954 | ||
| 6597 | 12년 전 | 946 | ||
| 6596 | 12년 전 | 434 | ||
| 6595 | 12년 전 | 796 | ||
| 6594 | 12년 전 | 4577 | ||
| 6593 | 12년 전 | 2582 | ||
| 6592 | 12년 전 | 834 | ||
| 6591 | 12년 전 | 597 | ||
| 6590 |
|
12년 전 | 1407 | |
| 6589 | 12년 전 | 780 | ||
| 6588 |
GINUSSOFT
|
12년 전 | 5134 | |
| 6587 | 12년 전 | 6217 | ||
| 6586 | 12년 전 | 1052 | ||
| 6585 | 12년 전 | 814 | ||
| 6584 | 12년 전 | 472 | ||
| 6583 |
|
12년 전 | 986 | |
| 6582 | 12년 전 | 876 | ||
| 6581 | 12년 전 | 850 | ||
| 6580 | 12년 전 | 624 | ||
| 6579 |
알랑가몰라
|
12년 전 | 938 | |
| 6578 | 12년 전 | 1336 | ||
| 6577 | 12년 전 | 1510 | ||
| 6576 |
경dragon
|
12년 전 | 782 | |
| 6575 | 12년 전 | 1892 | ||
| 6574 | 12년 전 | 692 | ||
| 6573 | 12년 전 | 997 | ||
| 6572 |
|
12년 전 | 1676 | |
| 6571 |
CTOMAN
|
12년 전 | 1970 | |
| 6570 | 12년 전 | 1741 | ||
| 6569 | 12년 전 | 1899 | ||
| 6568 | 12년 전 | 2411 | ||
| 6567 | 12년 전 | 1037 | ||
| 6566 |
lainfox
|
12년 전 | 1540 | |
| 6565 | 12년 전 | 3663 | ||
| 6564 |
제주프라이스
|
12년 전 | 1543 | |
| 6563 | 12년 전 | 1576 | ||
| 6562 |
프로프리랜서
|
12년 전 | 1357 | |
| 6561 |
프로프리랜서
|
12년 전 | 977 | |
| 6560 |
프로프리랜서
|
12년 전 | 1235 | |
| 6559 |
프로프리랜서
|
12년 전 | 1146 | |
| 6558 |
프로프리랜서
|
12년 전 | 1363 | |
| 6557 |
프로프리랜서
|
12년 전 | 1987 | |
| 6556 |
프로프리랜서
|
12년 전 | 1531 | |
| 6555 |
프로프리랜서
|
12년 전 | 1375 | |
| 6554 |
프로프리랜서
|
12년 전 | 3896 | |
| 6553 |
프로프리랜서
|
12년 전 | 1522 | |
| 6552 | 12년 전 | 858 | ||
| 6551 |
왕초보sasa
|
12년 전 | 1550 | |
| 6550 |
왕초보sasa
|
12년 전 | 645 | |
| 6549 |
왕초보sasa
|
12년 전 | 915 | |
| 6548 | 12년 전 | 1305 | ||
| 6547 | 12년 전 | 1205 | ||
| 6546 | 12년 전 | 5170 | ||
| 6545 | 12년 전 | 2527 | ||
| 6544 |
AnnieK
|
12년 전 | 1792 | |
| 6543 |
베르무트7
|
12년 전 | 655 | |
| 6542 |
오늘도망했다
|
12년 전 | 2241 | |
| 6541 | 12년 전 | 823 | ||
| 6540 | 12년 전 | 1147 | ||
| 6539 | 12년 전 | 856 | ||
| 6538 |
senseme
|
12년 전 | 3383 | |
| 6537 | 12년 전 | 783 | ||
| 6536 | 12년 전 | 3672 | ||
| 6535 | 12년 전 | 1359 | ||
| 6534 | 12년 전 | 1629 | ||
| 6533 | 12년 전 | 2255 | ||
| 6532 |
냐옹이사범
|
12년 전 | 2313 | |
| 6531 | 12년 전 | 574 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기