Jonathan Raasch가 게시 한 Simple jQuery Slideshow을 수정하려고합니다.DIV가 내용보다 왜 작습니까?
모든 이미지가 서로 번갈아 가며 흐리게 표시됩니다.
350px square image in a 350px height DIV container http://img154.imageshack.us/img154/904/fixed.jpg
그의 예는 고정 된 크기의 이미지와 함께 작동합니다. 대신 브라우저 윈도우의 백분율 너비 크기의 이미지로 작업하고 싶습니다.
이 고정 된 크기의 이미지와 함께 작동 ...
#slideshow {
...
height:350px;
}
#slideshow img {
...
}
내가 그것을 변경하는 방법이 ...
#slideshow {
...
}
#slideshow img {
...
width: 50%;
}
를 변경할 수 없기 내가 더 이상 명시 적으로 DIV의 높이를 설정하지 해요 "슬라이드 쇼"는 0으로 축소됩니다. 그러면 이미지가 내 텍스트를 덮습니다. 비교 ...
이것은 CSS와 자바 스크립트를 포함하여 내 모든 HTML 파일 ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en">
<head>
<title></title>
<style type="text/css">
#slideshow {
position:relative;
height:350px;
}
#slideshow img {
position:absolute;
top:0;
left:0;
z-index:8;
}
#slideshow img.active {
z-index:10;
}
#slideshow img.last-active {
z-index:9;
}
</style>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function slideSwitch() {
var $active = $('#slideshow img.active');
if ($active.length == 0) $active = $('#slideshow img:last');
var $next = $active.next().length ? $active.next()
: $('#slideshow img:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval("slideSwitch()", 5000);
});
</script>
</head>
<body>
<div id="slideshow">
<img src="img/img1.jpg" alt="" class="active" />
<img src="img/img2.jpg" alt="" />
<img src="img/img3.jpg" alt="" />
</div>
<p>Lorem ipsum ...</p>
</body>
</html>
이유는 그 내용보다는 내 DIV 작은? DIV 높이를 내용 높이와 어떻게 일치시킬 수 있습니까?
고맙습니다. CSS 전용 솔루션은 좀 더 우아하게 느껴지 겠지만 완벽하게 작동합니다. –