반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 85 | ||
| 8229 | 9년 전 | 78 | ||
| 8228 |
커네드커네드
|
9년 전 | 119 | |
| 8227 | 9년 전 | 136 | ||
| 8226 | 9년 전 | 172 | ||
| 8225 | 9년 전 | 158 | ||
| 8224 | 9년 전 | 152 | ||
| 8223 | 9년 전 | 120 | ||
| 8222 |
|
9년 전 | 199 | |
| 8221 | 9년 전 | 98 | ||
| 8220 | 9년 전 | 113 | ||
| 8219 | 9년 전 | 108 | ||
| 8218 | 9년 전 | 156 | ||
| 8217 |
star3840
|
9년 전 | 118 | |
| 8216 | 9년 전 | 168 | ||
| 8215 | 9년 전 | 125 | ||
| 8214 | 9년 전 | 231 | ||
| 8213 | 9년 전 | 171 | ||
| 8212 | 9년 전 | 87 | ||
| 8211 | 9년 전 | 258 | ||
| 8210 | 9년 전 | 254 | ||
| 8209 | 9년 전 | 344 | ||
| 8208 | 9년 전 | 233 | ||
| 8207 | 9년 전 | 237 | ||
| 8206 |
|
9년 전 | 198 | |
| 8205 | 9년 전 | 176 | ||
| 8204 | 9년 전 | 143 | ||
| 8203 | 9년 전 | 240 | ||
| 8202 | 9년 전 | 152 | ||
| 8201 | 9년 전 | 188 | ||
| 8200 | 9년 전 | 171 | ||
| 8199 | 9년 전 | 226 | ||
| 8198 | 9년 전 | 183 | ||
| 8197 | 9년 전 | 173 | ||
| 8196 | 9년 전 | 561 | ||
| 8195 | 9년 전 | 170 | ||
| 8194 | 9년 전 | 291 | ||
| 8193 | 9년 전 | 165 | ||
| 8192 | 9년 전 | 205 | ||
| 8191 | 9년 전 | 154 | ||
| 8190 | 9년 전 | 142 | ||
| 8189 | 9년 전 | 199 | ||
| 8188 | 9년 전 | 137 | ||
| 8187 | 9년 전 | 153 | ||
| 8186 | 9년 전 | 151 | ||
| 8185 | 9년 전 | 321 | ||
| 8184 | 9년 전 | 113 | ||
| 8183 | 9년 전 | 333 | ||
| 8182 | 9년 전 | 176 | ||
| 8181 | 9년 전 | 139 | ||
| 8180 | 9년 전 | 708 | ||
| 8179 | 9년 전 | 497 | ||
| 8178 | 9년 전 | 317 | ||
| 8177 |
kiplayer
|
9년 전 | 336 | |
| 8176 | 9년 전 | 361 | ||
| 8175 | 9년 전 | 232 | ||
| 8174 | 9년 전 | 257 | ||
| 8173 | 9년 전 | 352 | ||
| 8172 | 9년 전 | 209 | ||
| 8171 | 9년 전 | 190 | ||
| 8170 | 9년 전 | 302 | ||
| 8169 |
커네드커네드
|
9년 전 | 263 | |
| 8168 | 9년 전 | 329 | ||
| 8167 | 9년 전 | 326 | ||
| 8166 | 9년 전 | 245 | ||
| 8165 | 9년 전 | 178 | ||
| 8164 | 9년 전 | 309 | ||
| 8163 | 9년 전 | 294 | ||
| 8162 | 9년 전 | 309 | ||
| 8161 | 9년 전 | 303 | ||
| 8160 |
|
9년 전 | 503 | |
| 8159 | 9년 전 | 435 | ||
| 8158 | 9년 전 | 260 | ||
| 8157 | 9년 전 | 390 | ||
| 8156 | 9년 전 | 281 | ||
| 8155 | 9년 전 | 262 | ||
| 8154 |
00년생용띠
|
9년 전 | 605 | |
| 8153 | 9년 전 | 239 | ||
| 8152 |
|
9년 전 | 418 | |
| 8151 | 9년 전 | 415 | ||
| 8150 | 9년 전 | 513 | ||
| 8149 |
Jangfolk
|
9년 전 | 356 | |
| 8148 | 9년 전 | 180 | ||
| 8147 | 9년 전 | 382 | ||
| 8146 | 9년 전 | 448 | ||
| 8145 | 9년 전 | 395 | ||
| 8144 | 9년 전 | 362 | ||
| 8143 | 9년 전 | 203 | ||
| 8142 | 9년 전 | 432 | ||
| 8141 | 9년 전 | 386 | ||
| 8140 | 9년 전 | 937 | ||
| 8139 | 9년 전 | 268 | ||
| 8138 |
전갈자리남자
|
9년 전 | 394 | |
| 8137 | 9년 전 | 403 | ||
| 8136 | 9년 전 | 755 | ||
| 8135 |
|
9년 전 | 803 | |
| 8134 |
PlayPixel
|
9년 전 | 525 | |
| 8133 |
|
9년 전 | 449 | |
| 8132 | 9년 전 | 461 | ||
| 8131 | 9년 전 | 822 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기