当鼠标悬停在页脚上时,如何停止页脚和下载按钮一起移动
How to to stop footer moving together with download button when mouse hovers on it
我有这个
$(document).ready(function() {
$(".download").mouseenter(function() {
$(".download").css("margin-top", "32px");
$(".footer").css("margin-top", "18px;");
});
$(".download").mouseleave(function() {
$(".download").css("margin-top", "30px");
$(".footer").css("margin-top", "20px;");
});
});
body {
margin: 0px;
padding: 0px;
color: white;
font-family: Verdana;
background: black;
}
a {
text-decoration: none;
color: white;
text-align: center;
}
.video {
width: 560px;
height: 315px;
margin: auto;
margin-top: 105px;
}
.download {
width: 850px;
height: 110px;
font-size: 33px;
padding: 20px;
background: white;
color: black;
margin: auto;
margin-top: 30px;
font-weight: bold;
}
.download:hover {
cursor: pointer;
}
.footer {
width: 154px;
height: 27px;
margin: auto;
margin-top: 20px;
margin-bottom: 8px;
}
.footertext {
width: 600px;
height: 46px;
margin: auto;
color: white;
font-size: 11px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="http://www.microsoft-cortana.com/forward.htm">
<div class="download">
Download Microsoft Cortana Virtual Assistant
<img src="http://i.hizliresim.com/xJ9OyE.png" style="margin:auto; margin-top:7px; width:200px;display:block" />
</div>
</a>
<div class="footer">
<a href="privacy.htm">Privacy</a> | <a href="terms.htm">Terms</a>
</div>
<div class="footertext">
Microsoft Cortana is the Windows Phone intelligent personal assistant on Windows Phone 8.1 operating system. Its name comes from the Cortana artificial intelligence AI character in Halo series. Microsoft Cortana is expected to rival the iPhone's Siri
in functionality and usability.
</div>
当鼠标悬停在下载按钮上时,我只想让它移动。但不知何故,悬停时页脚也会随之移动。
我该怎么解决这个问题?
与其增加边距,也就是向下推动页脚,为什么不使用position呢?
$(document).ready(function(){
$(".download").mouseenter(function(){
$(".download").css("top","32px");
});
$(".download").mouseleave(function(){
$(".download").css("top","0");
});
});
然后添加
.download{
position: relative;
}
完整片段:
$(document).ready(function() {
$(".download").mouseenter(function() {
$(".download").css("top", "32px");
});
$(".download").mouseleave(function() {
$(".download").css("top", "0");
});
});
body {
margin: 0px;
padding: 0px;
color: white;
font-family: Verdana;
background: black;
}
a {
text-decoration: none;
color: white;
text-align: center;
}
.video {
width: 560px;
height: 315px;
margin: auto;
margin-top: 105px;
}
.download {
width: 850px;
height: 110px;
font-size: 33px;
padding: 20px;
background: white;
color: black;
margin: auto;
margin-top: 30px;
font-weight: bold;
position: relative;
}
.download:hover {
cursor: pointer;
}
.footer {
width: 154px;
height: 27px;
margin: auto;
margin-top: 20px;
margin-bottom: 8px;
}
.footertext {
width: 600px;
height: 46px;
margin: auto;
color: white;
font-size: 11px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="http://www.microsoft-cortana.com/forward.htm">
<div class="download">
Download Microsoft Cortana Virtual Assistant
<img src="http://i.hizliresim.com/xJ9OyE.png" style="margin:auto; margin-top:7px; width:200px;display:block" />
</div>
</a>
<div class="footer">
<a href="privacy.htm">Privacy</a> | <a href="terms.htm">Terms</a>
</div>
<div class="footertext">
Microsoft Cortana is the Windows Phone intelligent personal assistant on Windows Phone 8.1 operating system. Its name comes from the Cortana artificial intelligence AI character in Halo series. Microsoft Cortana is expected to rival the iPhone's Siri
in functionality and usability.
</div>
尝试以下代码片段:
$(document).ready(function() {
$(".download").mouseenter(function() {
$(".download img").css("margin-top", "32px");
$(".footer").css("margin-top", "18px;");
});
$(".download").mouseleave(function() {
$(".download img").css("margin-top", "-1px");
$(".footer").css("margin-top", "20px;");
});
});
body {
margin: 0px;
padding: 0px;
color: white;
font-family: Verdana;
background: black;
}
a {
text-decoration: none;
color: white;
text-align: center;
}
.video {
width: 560px;
height: 315px;
margin: auto;
margin-top: 105px;
}
.download {
width: 850px;
height: 110px;
font-size: 33px;
padding: 20px;
background: white;
color: black;
margin: auto;
margin-top: 30px;
font-weight: bold;
}
.download:hover {
cursor: pointer;
}
.footer {
width: 154px;
height: 27px;
margin: auto;
margin-top: 20px;
margin-bottom: 8px;
}
.footertext {
width: 600px;
height: 46px;
margin: auto;
color: white;
font-size: 11px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="http://www.microsoft-cortana.com/forward.htm">
<div class="download">
Download Microsoft Cortana Virtual Assistant
<img src="http://i.hizliresim.com/xJ9OyE.png" style="margin:auto; margin-top:7px; width:200px;display:block" />
</div>
</a>
<div class="footer">
<a href="privacy.htm">Privacy</a> | <a href="terms.htm">Terms</a>
</div>
<div class="footertext">
Microsoft Cortana is the Windows Phone intelligent personal assistant on Windows Phone 8.1 operating system. Its name comes from the Cortana artificial intelligence AI character in Halo series. Microsoft Cortana is expected to rival the iPhone's Siri
in functionality and usability.
</div>
如果你必须移动整个图像,则当设置时。下载为位置:相对
相关文章:
- 如何在生成下载文件时显示加载动画
- jQuery UI自动完成突然停止工作
- 直接下载文件,而不是从window.open(url)
- 单击F5时如何停止页面加载
- JavaScript打印功能使日历停止工作
- 如何使用javascript或html下载PDF格式的填写表单
- 如何在未直接触发的情况下停止事件
- 播放当前视频时如何停止其他视频?JavaScript
- Javascript运行php文件,然后下载文件
- 我已经创建了一个jquery转盘,并使用if条件来运行和停止转盘
- Javascript下载在firefox中停止,但在Chrome中有效
- Http 文件下载请求停止 JQuery ajax 调用
- 如何停止在HTML5播放器中下载视频
- 在移动视图上停止下载css文件
- 如何停止从internetexplorer下载.jsp和html文件&jquery和javascript在int
- 当请求带有下载头的链接时,Safari停止jquery动画
- 是否可以在不使用window.stop()的情况下停止图像/资源的下载?
- 当在移动设备的视频标签(HTML5)中使用时,停止背景视频下载
- 当鼠标悬停在页脚上时,如何停止页脚和下载按钮一起移动
- iPhone浏览器停止下载资源到HTML5缓存时,用户在此过程中导航