반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6930 |
SOFTA
|
11년 전 | 5984 | |
| 6929 |
|
11년 전 | 1596 | |
| 6928 | 11년 전 | 1759 | ||
| 6927 | 11년 전 | 1782 | ||
| 6926 | 11년 전 | 1885 | ||
| 6925 | 11년 전 | 2278 | ||
| 6924 | 11년 전 | 3875 | ||
| 6923 | 11년 전 | 2273 | ||
| 6922 |
level999
|
11년 전 | 1041 | |
| 6921 | 11년 전 | 822 | ||
| 6920 | 11년 전 | 961 | ||
| 6919 | 11년 전 | 1072 | ||
| 6918 | 11년 전 | 1312 | ||
| 6917 | 11년 전 | 15428 | ||
| 6916 | 11년 전 | 1426 | ||
| 6915 | 11년 전 | 588 | ||
| 6914 | 11년 전 | 618 | ||
| 6913 | 11년 전 | 880 | ||
| 6912 | 11년 전 | 3126 | ||
| 6911 |
사랑해요79
|
11년 전 | 969 | |
| 6910 | 11년 전 | 748 | ||
| 6909 | 11년 전 | 784 | ||
| 6908 | 11년 전 | 646 | ||
| 6907 | 11년 전 | 832 | ||
| 6906 | 11년 전 | 1588 | ||
| 6905 | 11년 전 | 571 | ||
| 6904 | 11년 전 | 1010 | ||
| 6903 | 11년 전 | 1679 | ||
| 6902 |
2donggalbi
|
11년 전 | 516 | |
| 6901 | 11년 전 | 1397 | ||
| 6900 | 11년 전 | 724 | ||
| 6899 | 11년 전 | 863 | ||
| 6898 |
열라뽕똬이
|
11년 전 | 1318 | |
| 6897 |
this1mg
|
11년 전 | 1618 | |
| 6896 |
sbdossb
|
11년 전 | 584 | |
| 6895 |
봉보로봉봉
|
11년 전 | 1158 | |
| 6894 |
똘똘이스머츠
|
11년 전 | 497 | |
| 6893 |
네이비컬러
|
11년 전 | 3640 | |
| 6892 | 11년 전 | 1078 | ||
| 6891 |
네이비컬러
|
11년 전 | 1322 | |
| 6890 | 11년 전 | 1145 | ||
| 6889 | 11년 전 | 591 | ||
| 6888 | 11년 전 | 728 | ||
| 6887 | 11년 전 | 619 | ||
| 6886 | 11년 전 | 5062 | ||
| 6885 | 11년 전 | 558 | ||
| 6884 |
asfasdfd235
|
11년 전 | 588 | |
| 6883 | 11년 전 | 3044 | ||
| 6882 | 11년 전 | 948 | ||
| 6881 | 11년 전 | 4435 | ||
| 6880 | 11년 전 | 1818 | ||
| 6879 |
퍼블리셔지노군
|
11년 전 | 2633 | |
| 6878 | 11년 전 | 563 | ||
| 6877 | 11년 전 | 585 | ||
| 6876 | 11년 전 | 1447 | ||
| 6875 | 11년 전 | 632 | ||
| 6874 | 11년 전 | 1603 | ||
| 6873 | 11년 전 | 1606 | ||
| 6872 | 11년 전 | 4462 | ||
| 6871 |
Abilityarch
|
11년 전 | 970 | |
| 6870 | 11년 전 | 2130 | ||
| 6869 | 11년 전 | 1410 | ||
| 6868 | 11년 전 | 1455 | ||
| 6867 | 11년 전 | 1527 | ||
| 6866 | 11년 전 | 745 | ||
| 6865 | 11년 전 | 1619 | ||
| 6864 | 11년 전 | 477 | ||
| 6863 | 11년 전 | 3751 | ||
| 6862 | 11년 전 | 1851 | ||
| 6861 | 11년 전 | 1647 | ||
| 6860 | 11년 전 | 1311 | ||
| 6859 |
cityman
|
11년 전 | 6817 | |
| 6858 | 11년 전 | 1272 | ||
| 6857 |
의정부아줌마
|
11년 전 | 874 | |
| 6856 | 11년 전 | 2376 | ||
| 6855 | 11년 전 | 1702 | ||
| 6854 | 11년 전 | 831 | ||
| 6853 | 11년 전 | 1210 | ||
| 6852 | 11년 전 | 2600 | ||
| 6851 | 11년 전 | 1978 | ||
| 6850 | 11년 전 | 1799 | ||
| 6849 | 11년 전 | 2089 | ||
| 6848 | 11년 전 | 2368 | ||
| 6847 | 11년 전 | 3146 | ||
| 6846 | 11년 전 | 2724 | ||
| 6845 | 11년 전 | 2802 | ||
| 6844 | 11년 전 | 3526 | ||
| 6843 | 11년 전 | 3272 | ||
| 6842 |
아트291
|
11년 전 | 698 | |
| 6841 | 11년 전 | 4173 | ||
| 6840 | 11년 전 | 5190 | ||
| 6839 | 11년 전 | 896 | ||
| 6838 |
|
11년 전 | 2097 | |
| 6837 | 11년 전 | 1282 | ||
| 6836 |
netdf
|
11년 전 | 619 | |
| 6835 |
|
11년 전 | 1013 | |
| 6834 | 11년 전 | 676 | ||
| 6833 |
|
11년 전 | 2691 | |
| 6832 |
울산굿모닝
|
11년 전 | 1664 | |
| 6831 |
|
11년 전 | 675 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기