와 '새로운 높이'로 이미지 크기를 조정 I 다음과 같습니다전환 배경 이미지는 jQuery를
HTML :
<div id="section-one" class="section">
<img id="section-one-img" style="width: 100%;" src="http://176.67.174.179/ukcctvinstallations.co.uk/wp-content/uploads/2014/09/section-one-pointers.jpg" />
<div id="section-one-headline">
<h1 class="main-headline"><span class="site-colour border-box">Your local CCTV Company</span> <br /><p class="headline-desc">with over 80 installation teams NATIONWIDE</span></h1>
</div>
</div>
jQuery를 :
jQuery(document).ready(function() {
if (jQuery(window).width() < 880) {
jQuery('#section-one-img').attr("src", 'http://176.67.174.179/ukcctvinstallations.co.uk/wp-content/uploads/2014/09/section-one-880px.jpg');
}
var imgHeight = jQuery('#section-one-img').height();
jQuery('#section-one-img').height(imgHeight);
});
올바른 새로운 이미지를로드하지만 화면 크기가 < 880이면 이미지의 새 높이가 설정되지 않습니다 (이미지의 아래쪽 부분이 잘립니다).
문제를 해결하기 위해 내 코드에 문제가 있습니까?
Fistly :
새 이미지의 높이는 어떻게되어야합니까? 그것은 항상 100 % 너비와 비율로 유지되어야합니까? –