<script>
function resizeImg() {
var windowWidth = $(window).width();
var windowHeight = $(window).height();
$("#content img, .resizablebox").each(function() {
var imgPosition = $(this).css('position');
if (imgPosition == 'absolute') {
var imgWidth = $(this).width();
var imgHeight = $(this).height();
var wRate = windowWidth / imgWidth;
var hRate = windowHeight / imgHeight;
if (wRate > hRate) {
var newWidth = imgWidth * hRate;
var newHeight = imgHeight * hRate;
} else {
var newWidth = imgWidth * wRate;
var newHeight = imgHeight * wRate;
}
$(this).css({
'width':newWidth+'px',
'height':newHeight+'px'
});
}
});
}
$(function() {
$("#content img, .resizablebox").each(function() {
var oImgWidth = $(this).width();
var oImgHeight = $(this).height();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
var imgPosition = $(this).css('position');
$(this).css({
'max-width':oImgWidth+'px',
'max-height':oImgHeight+'px'
});
if (imgPosition != 'absolute') {
$(this).css({
'width':'100%',
'height':'100%'
});
}
});
});
$(window).on('resize', resizeImg);
$(window).on('load', resizeImg);
</script>
<html></head>안에삽입
http://www.erzsamatory.net/86 참조
'etc.tip' 카테고리의 다른 글
Happy New year !! (0) | 2019.01.01 |
---|---|
페이지 이전다음버튼 소스 (0) | 2018.12.11 |
티스토리 스크롤 업다운버튼 소스 (0) | 2018.12.11 |
오른쪽 마우스 제한 해제(파이어폭스 확장) (0) | 2017.11.27 |
유튜브 동영상 티스토리 반응형 웹 스킨에 삽입하는 방법 (0) | 2017.04.21 |
좌우 여백에 이전글 다음글 표시 버튼 Script (0) | 2017.03.31 |
스크롤바를 내리면 나타나는 탑버튼 (0) | 2017.03.31 |
티스토리 미디어로그, 지역로그, 태그로그삽입 (0) | 2017.03.18 |
댓글