skin/board/gallery/list.skin.php 반응형으로 수정해보기
그누보드 기본 gallery 스킨의 list.skin.php 이미지 나열부분 자바스크립트로 반응형으로 수정하는 코드입니다.
<script>
$(function() {
var bo_gallery_cols = <?= isset($bo_gallery_cols) && is_numeric($bo_gallery_cols) ? $bo_gallery_cols : 4 ?>;
$('.gall_img').attr('style', '');
$('.gall_img > a').each(function(idx, el) {
var img_url = $(this).find('>img').attr('src');
$(this).css({
display: 'block',
position: 'relative',
width: '100%',
backgroundImage: 'url(' + img_url + ')',
paddingTop: '60%',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
border: '1px solid #ccc',
borderRadius: '4px'
});
});
$('.gall_img > a > img').hide();
$('.gall_img > a > .no_image,.gall_img > a > .is_notice').attr('style', '').css({
position: 'absolute',
left: '0px',
top: '0px',
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
});
function gall_ul() {
var ww = $(window).width();
var new_bgcs = 4;
//-----------------------{{{ 이부분을 넓이에 맞게 수정하세요
if (ww >= 992) {
new_bgcs = 4;
} else if (ww >= 768) {
new_bgcs = 3;
} else if (ww >= 576) {
new_bgcs = 2;
} else {
new_bgcs = 1;
}
//-----------------------
if (bo_gallery_cols == new_bgcs) return;
bo_gallery_cols = new_bgcs;
// 클레스 제거
var remove_class = 'box_clear';
for (var i = 0; i <= 10; i++) {
remove_class += ' col-gn-' + i;
}
$('#gall_ul .gall_li').removeClass(remove_class);
//클레스 추가
var add_row_class = 'col-gn-' + bo_gallery_cols;
$('#gall_ul .gall_li').addClass(add_row_class);
$('#gall_ul .gall_li').each(function(idx, el) {
var $this = $(this);
if (idx && (idx % bo_gallery_cols == 0)) {
$this.addClass('box_clear');
}
});
}
gall_ul();
$(window).resize(function() {
gall_ul();
});
});
</script>
<!-- 페이지 -->
<?php echo $write_pages; ?>
<!-- 페이지 -->
댓글 7개
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4402 | ||
| 2634 | 6개월 전 | 609 | ||
| 2633 | 6개월 전 | 599 | ||
| 2632 |
|
6개월 전 | 508 | |
| 2631 | 6개월 전 | 570 | ||
| 2630 |
세르반데스
|
6개월 전 | 538 | |
| 2629 | 6개월 전 | 728 | ||
| 2628 | 6개월 전 | 412 | ||
| 2627 | 6개월 전 | 418 | ||
| 2626 |
이슈DEV
|
7개월 전 | 637 | |
| 2625 |
welcome
|
7개월 전 | 645 | |
| 2624 |
이슈DEV
|
7개월 전 | 449 | |
| 2623 | 7개월 전 | 407 | ||
| 2622 | 7개월 전 | 496 | ||
| 2621 | 7개월 전 | 353 | ||
| 2620 |
|
7개월 전 | 370 | |
| 2619 | 7개월 전 | 479 | ||
| 2618 | 7개월 전 | 466 | ||
| 2617 | 7개월 전 | 555 | ||
| 2616 | 7개월 전 | 678 | ||
| 2615 | 7개월 전 | 582 | ||
| 2614 | 8개월 전 | 410 | ||
| 2613 |
바닐라코드
|
8개월 전 | 730 | |
| 2612 | 8개월 전 | 594 | ||
| 2611 | 8개월 전 | 731 | ||
| 2610 | 8개월 전 | 967 | ||
| 2609 | 8개월 전 | 508 | ||
| 2608 | 8개월 전 | 653 | ||
| 2607 | 8개월 전 | 631 | ||
| 2606 | 8개월 전 | 576 | ||
| 2605 | 8개월 전 | 602 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기