[英]Make an element appear and make adjustments when hovering over another element
I'm having problems with my code. 我的代码有问题。 I have it set up properly to show a hidden div mejs__horizontal-volume-slider
when you hover over mejs__volume-button
and shift other elements to the right to accommodate mejs__horizontal-volume-slider
. 我有它正确设置以显示隐藏的div mejs__horizontal-volume-slider
,当你将鼠标悬停在mejs__volume-button
等元素向右移,以适应mejs__horizontal-volume-slider
。 The problem I have is that mejs__horizontal-volume-slider
disappears when you move off mejs__volume-button
. 我的问题是,当您离开mejs__volume-button
时, mejs__horizontal-volume-slider
消失了。
I'm looking for a way to show mejs__horizontal-volume-slider
and adjust the volume when you hover over mejs__volume-button
and move over to mejs__horizontal-volume-slider
. 当您将鼠标悬停在mejs__volume-button
并移至mejs__horizontal-volume-slider
时,我正在寻找一种显示mejs__horizontal-volume-slider
并调整mejs__horizontal-volume-slider
。
URL: http://wpfreelance.bayoumedia.net/audio/ 网址: http : //wpfreelance.bayoumedia.net/audio/
JS code: JS代码:
$(document).ready(function() {
$('.mejs__volume-button').hover(
function () {
$('.mejs__horizontal-volume-slider').css({"display":"block"});
$('.mejs__time-slider').css({"width":"-moz-calc(100% - 50px)"});
$('.mejs__time-slider').css({"width":"-webkit-calc(100% - 50px)"});
$('.mejs__time-slider').css({"width":"calc(100% - 50px)"});
$('.mejs__speed-button').css({"right":"40px"});
},
function () {
$('.mejs__horizontal-volume-slider').css({"display":"none"});
$('.mejs__time-slider').css({"width":"100%"});
$('.mejs__speed-button').css({"right":"0"});
});});
Insert the slider and the button in the same container, and trigger the hover effect with the container, so when you're moving over the slider, you're still hovering the container. 将滑块和按钮插入同一容器中,并使用该容器触发悬停效果,因此,当您在滑块上移动时,仍将鼠标悬停在该容器上。 It's probably better to use CSS by the way. 顺便说一句,使用CSS可能更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.