반응형웹만들때 페이징때문에 고민하셨죠? 간편하게 제가 하나만들었습니다ㅎ
[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로 반응형웹을 짜는기술도 있공...자유롭게 하는방법에선 자바스크립트가 짱이더라고요ㅎ;
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7330 | 11년 전 | 1702 | ||
| 7329 | 11년 전 | 951 | ||
| 7328 | 11년 전 | 2243 | ||
| 7327 | 11년 전 | 1732 | ||
| 7326 | 11년 전 | 3832 | ||
| 7325 | 11년 전 | 2294 | ||
| 7324 | 11년 전 | 4534 | ||
| 7323 |
호식이와미돌
|
11년 전 | 1311 | |
| 7322 |
호식이와미돌
|
11년 전 | 1160 | |
| 7321 | 11년 전 | 1807 | ||
| 7320 | 11년 전 | 1780 | ||
| 7319 | 11년 전 | 1337 | ||
| 7318 |
|
11년 전 | 994 | |
| 7317 |
멋진남자임
|
11년 전 | 1634 | |
| 7316 |
잘살아보자
|
11년 전 | 1001 | |
| 7315 | 11년 전 | 1126 | ||
| 7314 | 11년 전 | 1345 | ||
| 7313 |
잘살아보자
|
11년 전 | 1139 | |
| 7312 | 11년 전 | 900 | ||
| 7311 |
사랑한데이
|
11년 전 | 2095 | |
| 7310 |
잘살아보자
|
11년 전 | 1908 | |
| 7309 |
잘살아보자
|
11년 전 | 3069 | |
| 7308 |
잘살아보자
|
11년 전 | 1030 | |
| 7307 |
잘살아보자
|
11년 전 | 790 | |
| 7306 | 11년 전 | 891 | ||
| 7305 |
잘살아보자
|
11년 전 | 2765 | |
| 7304 | 11년 전 | 1048 | ||
| 7303 | 11년 전 | 1248 | ||
| 7302 | 11년 전 | 756 | ||
| 7301 | 11년 전 | 1540 | ||
| 7300 |
mijaya
|
11년 전 | 1513 | |
| 7299 | 11년 전 | 932 | ||
| 7298 | 11년 전 | 1112 | ||
| 7297 | 11년 전 | 786 | ||
| 7296 | 11년 전 | 751 | ||
| 7295 | 11년 전 | 1578 | ||
| 7294 | 11년 전 | 931 | ||
| 7293 | 11년 전 | 826 | ||
| 7292 | 11년 전 | 916 | ||
| 7291 |
잘살아보자
|
11년 전 | 1105 | |
| 7290 |
잘살아보자
|
11년 전 | 782 | |
| 7289 | 11년 전 | 822 | ||
| 7288 |
잘살아보자
|
11년 전 | 1350 | |
| 7287 | 11년 전 | 847 | ||
| 7286 |
잘살아보자
|
11년 전 | 1348 | |
| 7285 | 11년 전 | 842 | ||
| 7284 | 11년 전 | 991 | ||
| 7283 | 11년 전 | 1018 | ||
| 7282 | 11년 전 | 786 | ||
| 7281 | 11년 전 | 823 | ||
| 7280 | 11년 전 | 1068 | ||
| 7279 | 11년 전 | 1987 | ||
| 7278 | 11년 전 | 826 | ||
| 7277 | 11년 전 | 834 | ||
| 7276 | 11년 전 | 767 | ||
| 7275 | 11년 전 | 1193 | ||
| 7274 | 11년 전 | 833 | ||
| 7273 | 11년 전 | 759 | ||
| 7272 | 11년 전 | 1080 | ||
| 7271 | 11년 전 | 1411 | ||
| 7270 | 11년 전 | 1035 | ||
| 7269 | 11년 전 | 973 | ||
| 7268 | 11년 전 | 1007 | ||
| 7267 | 11년 전 | 1854 | ||
| 7266 | 11년 전 | 911 | ||
| 7265 | 11년 전 | 965 | ||
| 7264 |
잘살아보자
|
11년 전 | 2730 | |
| 7263 |
잘살아보자
|
11년 전 | 2269 | |
| 7262 |
잘살아보자
|
11년 전 | 1146 | |
| 7261 |
잘살아보자
|
11년 전 | 1639 | |
| 7260 |
잘살아보자
|
11년 전 | 1261 | |
| 7259 | 11년 전 | 1178 | ||
| 7258 |
잘살아보자
|
11년 전 | 1307 | |
| 7257 |
잘살아보자
|
11년 전 | 1908 | |
| 7256 | 11년 전 | 956 | ||
| 7255 |
그누5입문
|
11년 전 | 1962 | |
| 7254 | 11년 전 | 2175 | ||
| 7253 |
|
11년 전 | 874 | |
| 7252 | 11년 전 | 1013 | ||
| 7251 | 11년 전 | 727 | ||
| 7250 | 11년 전 | 1698 | ||
| 7249 | 11년 전 | 1556 | ||
| 7248 |
sogo87
|
11년 전 | 1051 | |
| 7247 | 11년 전 | 947 | ||
| 7246 | 11년 전 | 716 | ||
| 7245 |
잘살아보자
|
11년 전 | 1091 | |
| 7244 | 11년 전 | 1541 | ||
| 7243 |
presee
|
11년 전 | 607 | |
| 7242 |
sogo87
|
11년 전 | 797 | |
| 7241 | 11년 전 | 914 | ||
| 7240 |
브라이언2
|
11년 전 | 924 | |
| 7239 |
|
11년 전 | 1141 | |
| 7238 | 11년 전 | 2638 | ||
| 7237 |
잘살아보자
|
11년 전 | 2278 | |
| 7236 |
dethos79
|
11년 전 | 1851 | |
| 7235 |
멋진남자임
|
11년 전 | 1416 | |
| 7234 | 11년 전 | 1358 | ||
| 7233 | 11년 전 | 2332 | ||
| 7232 | 11년 전 | 1610 | ||
| 7231 | 11년 전 | 2793 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기