반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6830 |
112211dd
|
11년 전 | 787 | |
| 6829 |
진짜다진짜가나타남
|
11년 전 | 1186 | |
| 6828 | 11년 전 | 817 | ||
| 6827 |
봉보로봉봉
|
11년 전 | 899 | |
| 6826 |
jinion
|
11년 전 | 815 | |
| 6825 | 11년 전 | 797 | ||
| 6824 |
yunkiri486
|
11년 전 | 713 | |
| 6823 |
2donggalbi
|
11년 전 | 847 | |
| 6822 | 11년 전 | 844 | ||
| 6821 | 11년 전 | 794 | ||
| 6820 | 11년 전 | 3100 | ||
| 6819 | 11년 전 | 1248 | ||
| 6818 | 11년 전 | 514 | ||
| 6817 |
|
11년 전 | 601 | |
| 6816 | 11년 전 | 2070 | ||
| 6815 | 11년 전 | 1208 | ||
| 6814 | 11년 전 | 852 | ||
| 6813 | 11년 전 | 598 | ||
| 6812 |
|
11년 전 | 980 | |
| 6811 | 11년 전 | 575 | ||
| 6810 | 11년 전 | 1534 | ||
| 6809 |
낚시가좋아
|
11년 전 | 1045 | |
| 6808 | 11년 전 | 437 | ||
| 6807 | 11년 전 | 757 | ||
| 6806 |
Unhappy
|
11년 전 | 1766 | |
| 6805 | 11년 전 | 1589 | ||
| 6804 | 11년 전 | 1115 | ||
| 6803 | 11년 전 | 550 | ||
| 6802 |
asdfg
|
11년 전 | 1130 | |
| 6801 |
아트귀농인
|
11년 전 | 498 | |
| 6800 | 11년 전 | 2551 | ||
| 6799 | 11년 전 | 1352 | ||
| 6798 | 11년 전 | 1466 | ||
| 6797 | 11년 전 | 623 | ||
| 6796 |
purple63
|
11년 전 | 425 | |
| 6795 | 11년 전 | 2630 | ||
| 6794 |
커네드커네드
|
11년 전 | 955 | |
| 6793 | 11년 전 | 399 | ||
| 6792 | 11년 전 | 2487 | ||
| 6791 | 11년 전 | 505 | ||
| 6790 | 11년 전 | 2248 | ||
| 6789 |
리아빌리티
|
11년 전 | 3090 | |
| 6788 | 11년 전 | 1341 | ||
| 6787 | 11년 전 | 670 | ||
| 6786 | 11년 전 | 386 | ||
| 6785 | 11년 전 | 714 | ||
| 6784 |
|
11년 전 | 837 | |
| 6783 | 11년 전 | 577 | ||
| 6782 | 11년 전 | 3651 | ||
| 6781 |
리아빌리티
|
11년 전 | 476 | |
| 6780 | 11년 전 | 517 | ||
| 6779 | 11년 전 | 475 | ||
| 6778 | 11년 전 | 4674 | ||
| 6777 |
바보온달123
|
11년 전 | 608 | |
| 6776 | 11년 전 | 921 | ||
| 6775 | 11년 전 | 722 | ||
| 6774 |
DANet
|
11년 전 | 633 | |
| 6773 | 11년 전 | 1557 | ||
| 6772 | 11년 전 | 1349 | ||
| 6771 | 11년 전 | 610 | ||
| 6770 | 11년 전 | 1155 | ||
| 6769 | 11년 전 | 943 | ||
| 6768 | 11년 전 | 680 | ||
| 6767 | 11년 전 | 575 | ||
| 6766 | 11년 전 | 1258 | ||
| 6765 |
크림나이트
|
11년 전 | 989 | |
| 6764 | 11년 전 | 1530 | ||
| 6763 | 11년 전 | 2590 | ||
| 6762 | 11년 전 | 523 | ||
| 6761 |
|
11년 전 | 777 | |
| 6760 |
|
11년 전 | 706 | |
| 6759 | 11년 전 | 3337 | ||
| 6758 | 11년 전 | 1005 | ||
| 6757 | 11년 전 | 1265 | ||
| 6756 | 11년 전 | 887 | ||
| 6755 |
|
11년 전 | 567 | |
| 6754 |
|
11년 전 | 708 | |
| 6753 |
|
11년 전 | 1373 | |
| 6752 | 11년 전 | 597 | ||
| 6751 |
|
11년 전 | 646 | |
| 6750 |
|
11년 전 | 2012 | |
| 6749 | 11년 전 | 1205 | ||
| 6748 |
|
11년 전 | 1111 | |
| 6747 | 11년 전 | 1154 | ||
| 6746 | 11년 전 | 826 | ||
| 6745 |
|
11년 전 | 902 | |
| 6744 | 11년 전 | 845 | ||
| 6743 | 11년 전 | 1272 | ||
| 6742 | 11년 전 | 526 | ||
| 6741 |
Abilityarch
|
11년 전 | 599 | |
| 6740 | 11년 전 | 638 | ||
| 6739 |
leewin20
|
11년 전 | 1227 | |
| 6738 | 11년 전 | 500 | ||
| 6737 | 11년 전 | 1210 | ||
| 6736 | 11년 전 | 1248 | ||
| 6735 | 11년 전 | 544 | ||
| 6734 | 11년 전 | 1277 | ||
| 6733 |
RipperTNT
|
11년 전 | 1835 | |
| 6732 |
|
11년 전 | 1334 | |
| 6731 |
|
11년 전 | 1384 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기