반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 9년 전 | 420 | ||
| 7829 |
|
9년 전 | 615 | |
| 7828 | 9년 전 | 539 | ||
| 7827 | 9년 전 | 432 | ||
| 7826 | 9년 전 | 435 | ||
| 7825 | 10년 전 | 480 | ||
| 7824 | 10년 전 | 445 | ||
| 7823 | 10년 전 | 383 | ||
| 7822 | 10년 전 | 360 | ||
| 7821 | 10년 전 | 309 | ||
| 7820 | 10년 전 | 348 | ||
| 7819 |
|
10년 전 | 751 | |
| 7818 | 10년 전 | 390 | ||
| 7817 | 10년 전 | 522 | ||
| 7816 | 10년 전 | 409 | ||
| 7815 | 10년 전 | 608 | ||
| 7814 | 10년 전 | 435 | ||
| 7813 | 10년 전 | 376 | ||
| 7812 | 10년 전 | 401 | ||
| 7811 | 10년 전 | 392 | ||
| 7810 | 10년 전 | 565 | ||
| 7809 | 10년 전 | 496 | ||
| 7808 | 10년 전 | 378 | ||
| 7807 | 10년 전 | 404 | ||
| 7806 |
프로그래머7
|
10년 전 | 1334 | |
| 7805 | 10년 전 | 1275 | ||
| 7804 |
zahir1312
|
10년 전 | 779 | |
| 7803 |
|
10년 전 | 1375 | |
| 7802 | 10년 전 | 457 | ||
| 7801 | 10년 전 | 861 | ||
| 7800 | 10년 전 | 1087 | ||
| 7799 | 10년 전 | 556 | ||
| 7798 | 10년 전 | 512 | ||
| 7797 | 10년 전 | 508 | ||
| 7796 | 10년 전 | 354 | ||
| 7795 | 10년 전 | 506 | ||
| 7794 | 10년 전 | 553 | ||
| 7793 | 10년 전 | 1056 | ||
| 7792 | 10년 전 | 474 | ||
| 7791 | 10년 전 | 557 | ||
| 7790 | 10년 전 | 504 | ||
| 7789 |
fbastore
|
10년 전 | 1449 | |
| 7788 | 10년 전 | 545 | ||
| 7787 | 10년 전 | 402 | ||
| 7786 | 10년 전 | 590 | ||
| 7785 | 10년 전 | 585 | ||
| 7784 | 10년 전 | 646 | ||
| 7783 | 10년 전 | 449 | ||
| 7782 | 10년 전 | 491 | ||
| 7781 | 10년 전 | 899 | ||
| 7780 | 10년 전 | 816 | ||
| 7779 | 10년 전 | 775 | ||
| 7778 | 10년 전 | 364 | ||
| 7777 | 10년 전 | 456 | ||
| 7776 | 10년 전 | 460 | ||
| 7775 | 10년 전 | 411 | ||
| 7774 | 10년 전 | 631 | ||
| 7773 | 10년 전 | 383 | ||
| 7772 | 10년 전 | 735 | ||
| 7771 | 10년 전 | 390 | ||
| 7770 | 10년 전 | 645 | ||
| 7769 | 10년 전 | 382 | ||
| 7768 | 10년 전 | 612 | ||
| 7767 | 10년 전 | 1173 | ||
| 7766 | 10년 전 | 492 | ||
| 7765 | 10년 전 | 526 | ||
| 7764 |
잘살아보자
|
10년 전 | 392 | |
| 7763 |
|
10년 전 | 1457 | |
| 7762 |
Tosea
|
10년 전 | 1056 | |
| 7761 | 10년 전 | 648 | ||
| 7760 |
잘살아보자
|
10년 전 | 676 | |
| 7759 |
잘살아보자
|
10년 전 | 508 | |
| 7758 |
잘살아보자
|
10년 전 | 594 | |
| 7757 | 10년 전 | 1246 | ||
| 7756 |
ITBANK
|
10년 전 | 1252 | |
| 7755 | 10년 전 | 1929 | ||
| 7754 | 10년 전 | 1054 | ||
| 7753 | 10년 전 | 885 | ||
| 7752 | 10년 전 | 1393 | ||
| 7751 |
잘살아보자
|
10년 전 | 533 | |
| 7750 |
잘살아보자
|
10년 전 | 478 | |
| 7749 |
잘살아보자
|
10년 전 | 490 | |
| 7748 |
잘살아보자
|
10년 전 | 494 | |
| 7747 |
잘살아보자
|
10년 전 | 588 | |
| 7746 |
잘살아보자
|
10년 전 | 675 | |
| 7745 |
잘살아보자
|
10년 전 | 917 | |
| 7744 |
잘살아보자
|
10년 전 | 416 | |
| 7743 | 10년 전 | 946 | ||
| 7742 |
starbros
|
10년 전 | 840 | |
| 7741 |
잘살아보자
|
10년 전 | 674 | |
| 7740 |
잘살아보자
|
10년 전 | 537 | |
| 7739 |
잘살아보자
|
10년 전 | 465 | |
| 7738 |
잘살아보자
|
10년 전 | 534 | |
| 7737 |
잘살아보자
|
10년 전 | 501 | |
| 7736 |
잘살아보자
|
10년 전 | 523 | |
| 7735 |
잘살아보자
|
10년 전 | 850 | |
| 7734 |
잘살아보자
|
10년 전 | 430 | |
| 7733 |
잘살아보자
|
10년 전 | 546 | |
| 7732 |
잘살아보자
|
10년 전 | 699 | |
| 7731 |
잘살아보자
|
10년 전 | 623 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기