【发布时间】:2009-06-02 01:45:29
【问题描述】:
我正在看一个 jQuery 截屏视频 (jQuery for Absolute Beginners: Day 8)。它有这个代码:
$(function() {
$('.wrap').hover(function() {
$(this).children('.front').stop().animate({
"top": '300px'
}, 900);
}, function() {
$(this).children('.front').stop().animate({
"top": '0'
}, 700);
});
});
#container {
width: 850px;
text-align: center;
margin: auto;
}
.wrap {
width: 250px;
height: 140px;
position: relative;
overflow: hidden;
padding: 0 1em;
}
img {
position: absolute;
top: 0;
left: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="container">
<div class="wrap">
<img src="back.jpg" alt="image" />
<img src="front.jpg" class="front" alt="image" />
</div>
</div>
为什么front.jpg出现在back.jpg之上?是不是因为front.jpg在back.jpg标签后面的标签中?
【问题讨论】:
-
这确实应该标记为html、css。我还建议您在深入研究 jquery 之前先熟悉 html/css,因为它通常用于操纵两者。
标签: javascript jquery html css