반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 130 | 20년 전 | 4010 | ||
| 129 | 20년 전 | 2949 | ||
| 128 | 20년 전 | 3687 | ||
| 127 | 20년 전 | 3523 | ||
| 126 | 20년 전 | 3775 | ||
| 125 | 20년 전 | 8595 | ||
| 124 | 20년 전 | 2604 | ||
| 123 | 20년 전 | 3755 | ||
| 122 | 20년 전 | 3213 | ||
| 121 | 20년 전 | 2615 | ||
| 120 | 20년 전 | 2675 | ||
| 119 | 20년 전 | 2589 | ||
| 118 | 20년 전 | 2864 | ||
| 117 |
|
20년 전 | 3064 | |
| 116 | 20년 전 | 5324 | ||
| 115 | 20년 전 | 3932 | ||
| 114 | 20년 전 | 4979 | ||
| 113 | 20년 전 | 6220 | ||
| 112 | 20년 전 | 7326 | ||
| 111 | 20년 전 | 18436 | ||
| 110 | 20년 전 | 6881 | ||
| 109 | 20년 전 | 2889 | ||
| 108 | 20년 전 | 4145 | ||
| 107 |
prosper
|
20년 전 | 2505 | |
| 106 |
prosper
|
20년 전 | 4322 | |
| 105 |
아우겐나이스
|
20년 전 | 2915 | |
| 104 | 20년 전 | 2265 | ||
| 103 | 20년 전 | 2481 | ||
| 102 | 20년 전 | 2264 | ||
| 101 | 20년 전 | 2580 | ||
| 100 | 20년 전 | 1757 | ||
| 99 | 20년 전 | 1574 | ||
| 98 | 20년 전 | 1620 | ||
| 97 | 20년 전 | 2133 | ||
| 96 | 20년 전 | 1886 | ||
| 95 | 20년 전 | 2382 | ||
| 94 | 20년 전 | 3568 | ||
| 93 | 20년 전 | 1568 | ||
| 92 | 20년 전 | 1765 | ||
| 91 | 20년 전 | 3184 | ||
| 90 | 21년 전 | 2346 | ||
| 89 | 21년 전 | 3182 | ||
| 88 | 21년 전 | 2872 | ||
| 87 | 21년 전 | 3300 | ||
| 86 | 21년 전 | 5138 | ||
| 85 | 21년 전 | 2528 | ||
| 84 | 21년 전 | 4832 | ||
| 83 | 21년 전 | 2510 | ||
| 82 | 21년 전 | 3128 | ||
| 81 | 21년 전 | 7636 | ||
| 80 | 21년 전 | 3836 | ||
| 79 | 21년 전 | 3216 | ||
| 78 | 21년 전 | 4700 | ||
| 77 | 21년 전 | 2909 | ||
| 76 | 21년 전 | 6226 | ||
| 75 | 21년 전 | 4475 | ||
| 74 | 21년 전 | 5788 | ||
| 73 | 21년 전 | 3632 | ||
| 72 | 21년 전 | 5975 | ||
| 71 | 21년 전 | 3121 | ||
| 70 | 21년 전 | 2849 | ||
| 69 | 21년 전 | 2645 | ||
| 68 | 21년 전 | 2451 | ||
| 67 | 21년 전 | 2660 | ||
| 66 | 21년 전 | 2680 | ||
| 65 | 21년 전 | 3793 | ||
| 64 | 21년 전 | 2834 | ||
| 63 | 21년 전 | 2462 | ||
| 62 | 21년 전 | 2272 | ||
| 61 | 21년 전 | 3084 | ||
| 60 | 21년 전 | 3136 | ||
| 59 | 21년 전 | 2523 | ||
| 58 | 21년 전 | 2594 | ||
| 57 | 21년 전 | 2974 | ||
| 56 | 21년 전 | 2337 | ||
| 55 | 21년 전 | 2765 | ||
| 54 | 21년 전 | 2133 | ||
| 53 | 21년 전 | 2359 | ||
| 52 | 21년 전 | 2704 | ||
| 51 |
prosper
|
21년 전 | 2354 | |
| 50 |
prosper
|
21년 전 | 2178 | |
| 49 | 21년 전 | 2183 | ||
| 48 | 21년 전 | 2345 | ||
| 47 | 21년 전 | 1937 | ||
| 46 | 21년 전 | 1934 | ||
| 45 | 21년 전 | 2137 | ||
| 44 | 21년 전 | 2368 | ||
| 43 | 21년 전 | 4585 | ||
| 42 |
prosper
|
21년 전 | 2717 | |
| 41 |
prosper
|
21년 전 | 2117 | |
| 40 | 21년 전 | 2183 | ||
| 39 | 21년 전 | 2154 | ||
| 38 | 21년 전 | 2426 | ||
| 37 | 21년 전 | 2573 | ||
| 36 | 21년 전 | 1781 | ||
| 35 | 21년 전 | 4078 | ||
| 34 | 21년 전 | 3855 | ||
| 33 | 21년 전 | 2995 | ||
| 32 |
prosper
|
21년 전 | 2908 | |
| 31 | 21년 전 | 5290 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기