Нужна помощь JQuery. Я нашел скрипт, который отображает миниатюры изображений с событием наведения мыши. Сценарий работает нормально, но по своему дизайну изображения отображаются вправо в зависимости от положения пикселя исходного эскиза.
Я хочу изменить положение всплывающего изображения таким образом, чтобы оно всегда находилось посередине экрана (или, что еще лучше, по центру внутри "div", заключающего "ul"), затем при наведении мыши оно возвращается к Расположение миниатюр. Но я не совсем уверен, как это сделать. Я попытался настроить расположение верхнего и левого мест в функции jquery .animate (), но смог заставить его работать правильно.
Любая помощь или советы будут оценены. Спасибо.
HTML:
<div>
<ul class="thumb_standard">
<li><a href="#"><img src="<?php echo $domain;?>images/screenshots/occupants1.png" alt="Tenants/Occupants"/></a></li>
<li><a href="#"><img src="<?php echo $domain;?>images/screenshots/occupants2.png" alt="Tenants/Occupants"/></a></li>
<li><a href="#"><img src="<?php echo $domain;?>images/screenshots/occupants3.png" alt="Tenants/Occupants"/></a></li>
</ul>
</div>
CSS:
/* Thumbnail popup display */
ul.thumb_standard {
/*float: left;*/
list-style: none;
margin: auto;
padding: 10px;
width: 900px;
}
ul.thumb_standard li {
margin: 0; padding: 5px;
float: left;
position: relative; /* Set the absolute positioning base coordinate */
width: 210px;
height: 110px;
}
ul.thumb_standard li img {
width: 200px; height: 100px; /* Set the small thumbnail size */
-ms-interpolation-mode: bicubic; /* IE Fix for Bicubic Scaling */
/*border: 1px solid #ddd;*/
padding: 5px;
/*background: #f0f0f0;*/
position: absolute;
left: 0; top: 0;
}
ul.thumb_standard li img.hover {
background:url(thumb_bg.png) no-repeat center center; /* Image used as background on hover effect
border: none; /* Get rid of border on hover */
}
.thumb_container{margin:auto;}
/* END THUMBNAIL DISPLAY */
JQuery:
<script type="text/javascript">
$("ul.thumb_standard li").hover(function() {
$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/
$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
.animate({
/* The next 4 lines will vertically align this image */
marginTop: '-210px',
marginLeft: '-110px',
top: '50%',
left: '50%',
width: '700px', /* Set new width */
height: '500px', /* Set new height */
padding: '20px'
}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
} , function() {
$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
$(this).find('img').removeClass("hover").stop() /* Remove the "hover" class , then stop animation queue buildup*/
.animate({
marginTop: '0', /* Set alignment back to default */
marginLeft: '0',
top: '0',
left: '0',
width: '200px', /* Set width back to default */
height: '100px', /* Set height back to default */
padding: '5px'
}, 400);
});
</script>