HTML+CSS+JS 模仿 Win10 亮度调节效果

阅读 3869  ·  发布日期 2020-08-24 11:45  ·  温州雄霸网络科技有限公司|建站|APP小程序制作|做网站SEO推广优化
【摘要】 HTML+CSS+JS模仿win10亮度调节效果代码 模仿win10的亮度调... 【温州小程序开发,温州微信公众号,平阳做网站,平阳网站建设公司,平阳小程序商城制作,昆阳万全做网站,鳌江水头小程序,萧江腾蛟微信公众号,山门顺溪南雁海西南麂凤卧麻步怀溪网络网店服务,政采云网店管理服务】...

HTML+CSS+JS 模仿 Win10 亮度调节效果

HTML+CSS+JS模仿win10亮度调节效果代码

模仿win10的亮度调节

1.将各个元素的样子写出来这里为了方便好观察给body添加了一个背景颜色html

cssbody{
background:back;
}
.control_bar{
height:200px;
width:500px;
border-bottom:3px solid #888888;
}
.control_bar_cursor{
height:25px;
width:8px;
background: #505151;
border-radius:5px;
}
效果图2. 将各个元素叠到一起cssbody{
background:black;
}
.control_bar{
height:200px;
width:500px;
border-bottom:3px solid #888888;
}
.control_bar_cursor{
height:25px;
width:8px;
background: #505151;
border-radius:5px;
margin-top:-12.5px;
position:relative;
top:0;
left:0;
}
.control_bar_cursor:hover{
background:white;
}
#control_bar_mask{
margin-top:-203px;
width:100px;
}
这里为了显示遮罩效果把遮罩层的p宽度设小了3. 添加jsjswindow.onload = function(){
var control_bar = document.getElementsByClassName("control_bar")[0];
var control_bar_mask = document.getElementById("control_bar_mask");
var control_bar_cursor = document.getElementsByClassName("control_bar_cursor")[0];
var def_left = control_bar_cursor.offsetLeft;
document.body.onmousedown = function(){
window.onmousemove = function(){
var cursor_X = event.clientX;
var cursor_Y = event.clientY;
if(cursor_X control_bar_cursor.style.left = 0;
}
else if(cursor_X > control_bar.offsetWidth + def_left){
control_bar_cursor.style.left = control_bar.offsetWidth;
}
else{
control_bar_cursor.style.left = cursor_X - def_left + "px";
}
var proportion = parseInt(control_bar_cursor.offsetLeft - def_left) / parseInt(control_bar.offsetWidth - 1);
control_bar_mask.style.width = proportion * control_bar.offsetWidth + "px";
}
;
window.onmouseup = function(){
window.onmousemove = null;
}
;
}
;
}
;
4. 添加一个mask用控制条来控制其透明度达到亮度调节效果

.mask{
position:fixed;
bottom:0;
top:0;
left:0;
right:0;
background:black;
z-index:-1;
}
window.onload = function(){
var control_bar = document.getElementsByClassName("control_bar")[0];
var control_bar_mask = document.getElementById("control_bar_mask");
var control_bar_cursor = document.getElementsByClassName("control_bar_cursor")[0];
var def_left = control_bar_cursor.offsetLeft;
var mask = document.getElementsByClassName("mask")[0];
document.body.onmousedown = function(){
window.onmousemove = function(){
var cursor_X = event.clientX;
var cursor_Y = event.clientY;
if(cursor_X control_bar_cursor.style.left = 0;
}
else if(cursor_X > control_bar.offsetWidth + def_left){
control_bar_cursor.style.left = control_bar.offsetWidth;
}
else{
control_bar_cursor.style.left = cursor_X - def_left + "px";
}
//亮度比 var proportion = parseInt(control_bar_cursor.offsetLeft - def_left) / parseInt(control_bar.offsetWidth - 1);
control_bar_mask.style.width = proportion * control_bar.offsetWidth + "px";
mask.style.opacity = 1 - proportion;
}
;
window.onmouseup = function(){
window.onmousemove = null;
}
;
}
;
}
;
推荐教程:
《HTML教程》以上就是HTML+CSS+JS 模仿 Win10 亮度调节效果的详细内容,更多请关注php中文网其它相关文章!
微信
分享相关标签:
html css win10 亮度调节本文转载于:
jb51,如有侵犯,请联系a@php.cn删除
上一篇:
html文档的基本结构由哪三对标签负责组织
下一篇:
HTML5 移动端自适应布局相关文章相关视频在html语言中,单元格的标记是什么如何查看html文件的代码?HTML5 和 Flash 区别?php不显示html怎么办HTML如何设置网页标题?HTML+CSS+JS 模仿 Win10 亮度调节...HTML5中新增加的标签HTML5废除的元素HTML5新增的属性和废除的属性HTML5的高级功能介绍 [温州做网站html教程]