【发布时间】:2018-07-25 18:30:46
【问题描述】:
我有一个图像,我想让覆盖的文本在鼠标悬停时移动(我也尝试过悬停但没有更好的结果)并且文本想要在鼠标悬停时反弹。
CSS
.backgroundImage {
/*opacity: .7;*/
display: block;
width: 100%;
height: auto;
}
HTML
section style="float: left;">
<img src="_images/engaged-buying-a-home.jpg" alt="Avatar"
class="backgroundImage" style="width:82%; ">
</section>
<section id="textbox" style="clear: both; float: left; width: 48%; height:
18em;
margin-top: -18em; z-index: 10;">
<p style="font-size: 2.0em; margin-top: 6.5em; margin-left: 4.5em;
color: #FFF; z-index: 10;" >Seller Services</p>
<a href="sellers.html"><p id="learn" style="font-size: 1.5em; margin-top:
-1em; margin-left: 6.0em; border: 1px solid #FFF; color: #000; padding:
.5em 1em; width: 8em; display: none;">Read More →
</p></a>
</section>
jQuery:
<script>
$(document).ready(function(){
$("#textbox").mouseenter(function(){
$(this).animate({marginTop: "-=200px"},2000)
});
});
</script>
<script>
$(document).ready(function(){
$("#textbox").mouseenter(function(){
$("#learn").show(200)
});
});
</script>
<script>
$(document).ready(function(){
$("#textbox").mouseleave(function(){
$(this).animate({marginTop: "+=200px"},2000)
});
});
</script>
<script>
$(document).ready(function(){
$("#textbox").mouseleave(function(){
$("#learn").hide(200)
});
});
</script>
顺便说一句,我计划在 CSS 工作后将样式放入 CSS 中。任何帮助将不胜感激。
谢谢
【问题讨论】: