【发布时间】:2016-12-19 22:25:24
【问题描述】:
我有一个 HTML 5 range 元素。我需要做的是当用户将鼠标悬停在范围上时,拇指的高度和宽度应该增加到 12 像素。
CSS
.myrange::-webkit-slider-thumb{
position:relative;
top:-5px;
appearance:none;
-webkit-appearance:none;
-webkit-transition: width 2s, height 4s;
transition: width 2s, height 4s;
border-radius:50px;
background-color:rgb(9,90,0);
border:0;
cursor:pointer;
visibility:hidden;
}
JavaScript
var skb_rhdaseek = $("<style>", {"type": "text/css"}).appendTo("head");
$('.myrange').hover(function(){
skb_rhdaseek.text('.myrange::-webkit-slider-thumb{height:12px; width:12px;}');
});
【问题讨论】:
-
$(hoverelem).hover(function(){ $(anotherleelem).animate(function(){}); }); -
您的代码有很多问题,而且从外观上看,您正在尝试更改同一元素的样式。
-
@RajshekarReddy 这就是为什么我自己做不到的原因,我的代码并不重要,如果您有更好的方法在
range itselft悬停时为range thumb设置动画,我将不胜感激!
标签: javascript jquery css html css-transitions