반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6530 |
퍼블리셔강
|
12년 전 | 654 | |
| 6529 | 12년 전 | 1308 | ||
| 6528 | 12년 전 | 628 | ||
| 6527 | 12년 전 | 792 | ||
| 6526 | 12년 전 | 6581 | ||
| 6525 | 12년 전 | 552 | ||
| 6524 | 12년 전 | 842 | ||
| 6523 | 12년 전 | 496 | ||
| 6522 | 12년 전 | 541 | ||
| 6521 | 12년 전 | 802 | ||
| 6520 | 12년 전 | 744 | ||
| 6519 | 12년 전 | 1745 | ||
| 6518 |
가슴시린하늘
|
12년 전 | 1726 | |
| 6517 | 12년 전 | 1366 | ||
| 6516 | 12년 전 | 5228 | ||
| 6515 | 12년 전 | 1501 | ||
| 6514 | 12년 전 | 1602 | ||
| 6513 | 12년 전 | 956 | ||
| 6512 | 12년 전 | 1988 | ||
| 6511 | 12년 전 | 1375 | ||
| 6510 | 12년 전 | 3079 | ||
| 6509 |
프로프리랜서
|
12년 전 | 2551 | |
| 6508 |
프로프리랜서
|
12년 전 | 1900 | |
| 6507 |
프로프리랜서
|
12년 전 | 2376 | |
| 6506 |
프로프리랜서
|
12년 전 | 1859 | |
| 6505 |
프로프리랜서
|
12년 전 | 1635 | |
| 6504 | 12년 전 | 1046 | ||
| 6503 | 12년 전 | 1132 | ||
| 6502 |
프로프리랜서
|
12년 전 | 5557 | |
| 6501 |
프로프리랜서
|
12년 전 | 2607 | |
| 6500 |
프로프리랜서
|
12년 전 | 3090 | |
| 6499 |
프로프리랜서
|
12년 전 | 1752 | |
| 6498 |
프로프리랜서
|
12년 전 | 1465 | |
| 6497 | 12년 전 | 816 | ||
| 6496 |
yunkiri486
|
12년 전 | 1816 | |
| 6495 | 12년 전 | 924 | ||
| 6494 | 12년 전 | 1492 | ||
| 6493 | 12년 전 | 2763 | ||
| 6492 |
오늘도망했다
|
12년 전 | 2338 | |
| 6491 |
오늘도망했다
|
12년 전 | 1678 | |
| 6490 |
오늘도망했다
|
12년 전 | 6661 | |
| 6489 |
오늘도망했다
|
12년 전 | 2500 | |
| 6488 |
홈피119
|
12년 전 | 704 | |
| 6487 | 12년 전 | 688 | ||
| 6486 | 12년 전 | 1412 | ||
| 6485 | 12년 전 | 2054 | ||
| 6484 | 12년 전 | 903 | ||
| 6483 | 12년 전 | 724 | ||
| 6482 | 12년 전 | 1345 | ||
| 6481 | 12년 전 | 1474 | ||
| 6480 |
Header
|
12년 전 | 692 | |
| 6479 |
|
12년 전 | 1130 | |
| 6478 |
개초보제이
|
12년 전 | 1396 | |
| 6477 | 12년 전 | 805 | ||
| 6476 | 12년 전 | 1077 | ||
| 6475 | 12년 전 | 3687 | ||
| 6474 | 12년 전 | 1431 | ||
| 6473 | 12년 전 | 963 | ||
| 6472 | 12년 전 | 859 | ||
| 6471 |
AMDbest
|
12년 전 | 1207 | |
| 6470 |
jinmuk
|
12년 전 | 1448 | |
| 6469 |
jinmuk
|
12년 전 | 4251 | |
| 6468 |
jinmuk
|
12년 전 | 5582 | |
| 6467 | 12년 전 | 707 | ||
| 6466 |
jinmuk
|
12년 전 | 2282 | |
| 6465 |
jinmuk
|
12년 전 | 6740 | |
| 6464 |
jinmuk
|
12년 전 | 2411 | |
| 6463 |
jinmuk
|
12년 전 | 9337 | |
| 6462 |
희망과열정
|
12년 전 | 541 | |
| 6461 |
Header
|
12년 전 | 728 | |
| 6460 |
희망과열정
|
12년 전 | 1363 | |
| 6459 |
프리랜서개발자
|
12년 전 | 1679 | |
| 6458 | 12년 전 | 1343 | ||
| 6457 |
jinmuk
|
12년 전 | 1953 | |
| 6456 |
jinmuk
|
12년 전 | 2351 | |
| 6455 |
jinmuk
|
12년 전 | 3213 | |
| 6454 |
jinmuk
|
12년 전 | 2179 | |
| 6453 |
jinmuk
|
12년 전 | 2364 | |
| 6452 |
jinmuk
|
12년 전 | 2319 | |
| 6451 |
jinmuk
|
12년 전 | 1614 | |
| 6450 |
jinmuk
|
12년 전 | 1404 | |
| 6449 |
jinmuk
|
12년 전 | 1049 | |
| 6448 |
jinmuk
|
12년 전 | 1252 | |
| 6447 |
jinmuk
|
12년 전 | 2015 | |
| 6446 |
jinmuk
|
12년 전 | 1575 | |
| 6445 |
jinmuk
|
12년 전 | 1266 | |
| 6444 |
jinmuk
|
12년 전 | 2315 | |
| 6443 |
jinmuk
|
12년 전 | 2049 | |
| 6442 |
jinmuk
|
12년 전 | 1895 | |
| 6441 |
jinmuk
|
12년 전 | 1626 | |
| 6440 |
jinmuk
|
12년 전 | 2324 | |
| 6439 |
jinmuk
|
12년 전 | 1139 | |
| 6438 |
wndProc
|
12년 전 | 788 | |
| 6437 | 12년 전 | 410 | ||
| 6436 |
senseme
|
12년 전 | 554 | |
| 6435 | 12년 전 | 1050 | ||
| 6434 | 12년 전 | 2485 | ||
| 6433 | 12년 전 | 2492 | ||
| 6432 | 12년 전 | 1567 | ||
| 6431 |
밥먹고합시다
|
12년 전 | 1194 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기