반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 20097 | |
| 20095 | |
| 20093 | |
| 20092 | |
| 20091 | |
| 20089 | |
| 20086 | |
| 20085 | |
| 20084 | |
| 20083 | |
| 20082 | |
| 28358 | |
| 20081 | |
| 20079 | |
| 20078 | |
| 20077 | |
| 20076 | |
| 20075 | |
| 20074 | |
| 20073 |
PHP
php환경 변수 출력 입니다.
|
| 20072 |
PHP
PHP팁 (보안 등) 입니다.
|
| 20071 |
PHP
문자열 자르는 함수 입니다.
|
| 20070 | |
| 20069 | |
| 8148 | |
| 20057 |
정규표현식
파싱 예제입니다.
11
|
| 8141 | |
| 24669 | |
| 20056 | |
| 8138 | |
| 28353 | |
| 20055 | |
| 20054 | |
| 20053 | |
| 20052 | |
| 20051 | |
| 20050 |
JavaScript
지난 시간 경과시간 페이스북 sns 처럼 보여주기 javascript 버전
|
| 20047 | |
| 20046 |
PHP
php환경맞춤 부분 입니다.
|
| 20045 | |
| 20044 | |
| 8111 | |
| 20043 | |
| 20042 | |
| 20040 | |
| 20039 |
JavaScript
구글 맞춤검색 설정 방법, google custom search
|
| 20037 | |
| 20036 | |
| 20035 | |
| 20027 |
MySQL
1000만건 게시판에 도전합니다. 두번째
7
|
| 8107 | |
| 31022 | |
| 20026 |
MySQL
Join 을 이용한 delete
|
| 20025 | |
| 20024 | |
| 20023 |
PHP
미리 정의된 변수들 입니다.
|
| 28350 | |
| 20022 | |
| 20018 |
MySQL
1000만건 게시판에 도전합니다. 첫번째
3
|
| 20017 |
MySQL
select 해서 바로 insert하기
|
| 8099 | |
| 20016 | |
| 20013 | |
| 8090 | |
| 20012 | |
| 20010 | |
| 20009 | |
| 19998 |
PHP
텔레그램 푸쉬 봇
10
|
| 28348 | |
| 28347 | |
| 19997 | |
| 19996 |
OS
파일분할 분할압축 해제
|
| 19995 |
웹서버
리눅스백그라운드실행
|
| 19993 | |
| 8087 | |
| 8065 | |
| 19990 | |
| 8063 | |
| 8056 | |
| 19989 | |
| 19988 | |
| 19987 | |
| 19986 | |
| 19985 | |
| 19984 | |
| 19983 | |
| 19982 |
MySQL
mysql에서 boolean 타입 사용하기
|
| 8054 | |
| 19981 | |
| 19980 | |
| 19979 |
MySQL
mysqladmin 상태 모니터링
|
| 19978 | |
| 19977 | |
| 19976 |
웹서버
리눅스 프로세스 검사, 조회
|
| 19975 |
웹서버
리눅스에서 네트워크 상태 보기
|
| 19974 |
웹서버
리눅스 80 포트 방화벽 열기
|
| 19973 | |
| 19972 |
MySQL
Mysql Table 일괄 삭제 방법.
|
| 19971 | |
| 19970 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기