input range样式更改,模拟滑块
input range 样式更改,js模拟滑块实时更新数据。
效果图:
html 代码:
<div>
<span class="slider"></span>
<span class="lightgray"></span>
<input type="range" min="0" max="5" step="0.1" value="0">
<span class="value"><span class="min">0</span>-5</span>
</div>
css 代码:
div{
position: relative;
}
input[type=range] {
-webkit-appearance: none; /* 隐藏滑块,以便自定义滑块样式 */
width: 120px;
border: none;
position: absolute;
background: transparent;
z-index: 3;
top: 20px;
&:before {
content: attr(min);
padding-right: 5px;
}
&:after {
content: attr(max);
padding-left: 5px;
}
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
}
input[type=range]:focus {
outline: none; /* 去掉默认蓝色边框 */
}
input[type=range]::-ms-track {
width: 100%;
cursor: pointer;
background: transparent; /* 隐藏滑块,以便自定义滑块样式 */
border-color: transparent;
color: transparent;
}
/* 设定WebKit浏览器下range */
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
height: 10px;
width: 10px;
border-radius: 100%;
background: orange;
cursor: pointer;
margin-top: -2px;
margin-left: -1px;
}
/* Firefox下 */
input[type=range]::-moz-range-thumb {
height: 10px;
width: 10px;
border-radius: 100%;
background: orange;
cursor: pointer;
margin-left: -1px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 6px;
cursor: pointer;
background: transparent;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: transparent;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 6px;
cursor: pointer;
background: transparent;
}
input[type=range]::-ms-track {
width: 100%;
height: 6px;
cursor: pointer;
background: transparent;
border-color: transparent;
border-width: 16px 0;
color: transparent;
}
.lightgray {
position: absolute;
top: 22px;
left: 2px;
height: 6px;
display: inline-block;
background-color: lightgray;
z-index: 2;
}
.slider{
position: absolute;
top: 22px;
left: 2px;
height: 6px;
display: inline-block;
background-color: #ef6683;
width: 118px;
}
.value{
margin-left: 30px;
}
js代码:
$("input").on("mousemove",function(){
var $this = $(this);
var $min = $this.closest('div').find('.value .min');
var value = parseFloat($this.val());
$min.text(value.toFixed(1));
var $lightgray = $this.closest('div').find('.lightgray');
var $slider = $this.closest('div').find('.slider');
var width = $slider.width() / $this.attr('max') * value;
$lightgray.css('width', width);
});
input range样式更改,模拟滑块的更多相关文章
- input range样式优化
首先HTML代码: <input id="snrPollInterval" type="range" min="1" max=&quo ...
- 【转】自定义(滑动条)input[type="range"]样式
1.如何使用滑动条? 用法很简单,如下所示: <input type="range" value="0"> 各浏览器原始样式如下: Chrome: ...
- [js开源组件开发]html5标签audio的样式更改
html5标签audio的样式更改 由于html5的流行,现在移动端大多数的需求都可以使用audio来播放音频,但您可能只是需要很简单的播放/停止效果,但不同的浏览器上的audio样式却不尽人意,所以 ...
- input输入样式,动画
模板描述:input输入样式 动画,有输入框也有搜索框的样式,多种多样,大家根据自己的喜欢来. 找网站SEO教程,网站模板,以及想要建立个人博客的朋友来涂志海个人博客网,这里有你想要的一切(万一没有的 ...
- 自定义input file样式
自定义input file样式:一般都是通过隐藏input,通过定义label来实现.这种做法要注意的是label的for属性要指定input对应的id; <!DOCTYPE html> ...
- input的样式简介
<input type="text" autocomplete="off" placeholder="" x-webkit-speec ...
- Vue获取DOM元素样式 && 样式更改
在 vue 中用 document 获取 dom 节点进行节点样式更改的时候有可能会出现 'style' is not definde的错误, 这时候可以在 mounted 里用 $refs 来获取样 ...
- input:file样式怎样修改
问题描述: 我需要点击input:file来修改img中的图片,但是input:file样式太丑 解决办法: 给file设置透明度为0,让用户看不见他 创建新的button按钮 修改button按钮样 ...
- 使用input range滑块,控制元素transform rotate旋转样式
<!DOCTYPE html> <html> <head> </head> <body> <!-- 第一步:设置div旋转对象和inp ...
随机推荐
- .NET 事件
事件概述 在发生其他类或对象关注的事情时,类或对象可通过事件通知它们.发 ...
- MySQL通过增加用户实现远程连接数据库
命令行进入mysql.exe所在目录 mysql -uroot -padmin 例子: grant all privileges on *.* to joe@localhost identified ...
- Centos7设置关闭防火墙
CentOS 7.0默认使用的是firewall作为防火墙,要想使用iptables必须重新设置一下. 1.关闭防火墙 [root@localhost ~]# systemctl stop firew ...
- EasyUI第一章Application之Basic CRUD(增删改查)
先看效果图: 增加: 修改: 删除: 具体实现: html与js代码: @{ Layout = null; } <!DOCTYPE html> <html> <head& ...
- Git命令之资源
https://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%9A%84%E6%96%B0%E5%BB%BA% ...
- 事务操作(BEGIN/COMMIT/ROLLBACK/SAVE TRANSACTION)
BEGIN TRANSACTION 标记一个显式本地事务的起始点. BEGIN TRANSACTION 使 @@TRANCOUNT 按 1 递增. BEGIN TRANSACTION 代表一点,由连接 ...
- DevExpress的GridControl的实时加载数据解决方案(取代分页)
http://blog.csdn.net/educast/article/details/4769457 evExpress是一套第三方控件 其中有类似DataGridView的控件 今天把针对Dev ...
- 关于vector的内存释放问题
以前一直想当然的以为vector 的clear()函数会保证释放vector的内存,今天网上一查资料发现完全不是我想象的那样子. 比如有如下代码: tempObject obj1; tempObjec ...
- HTML5页面绘图
canvas 标签:获取画笔: 对象.getContext("2d")制定画笔Syte: context.fillStyle = "red"; context. ...
- HDU5900 QSC and Master(区间DP + 最小费用最大流)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5900 Description Every school has some legends, ...