亚洲女同成aV人片在线观看|亚洲www啪成人一区二区麻豆|亚洲国产中日韩精品综合|亚洲国产成人精品一级片|亚洲无码在线视频免费

天津九安特機電工程有限公司

關(guān)鍵詞優(yōu)化

HTML+CSS+JS模仿win10亮度調節效果的示例代碼

這篇文章主要介紹了HTML+CSS+JS模仿win10亮度調節效果的模碼示例代碼,本文通過(guò)實(shí)例代??碼給大家介紹的非常??詳細,對大家的亮度例代學(xué)習或工作具有一定的參考借鑒價(jià)值,需要的調節的示朋友可以參考下

HTML+CSS+JS模仿win10亮度調節效果

代碼

<!doctype html>
<h??tml>
<head>
<meta chars??et='utfヽ(′▽?zhuān)?ノ-8'>
<title>模仿win10的亮度調節</title>
<style>
.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:hov??er{
background:white;
}
#control_bar_mask{
margin-top:-203px;
width:0px;
}
.mask{
position:fixed;
bottom:0;
top:0;
left:0;
right:0;
background:black;
z-index:-1;
}
</style>
</head>
<body>
<div class="mask"></div>
<div class='control_bar'></div&g(′?ω?`)t;
<div class="control_bar" style="border-botto??m:3px solid #505151;" id="control_bar(′?ω?`)_mask"&g(′_`)t;</div>
<div class='control_bar_cursor'></div>
</body>
<script>
window.onload = funct?ion(){
var control_bar = document.getElementsByClassName("control_bar")[0];
var control_bar_mask = docume(╯‵□′)╯nt.getElementById("control_bar_mask");
var control_bar_cursor = document.getElementsByClass??Name("control_bar_cursor")[0];
var def_left = control_bar_cursor.offsetLeft;
var mask = document.getElementsByClassNam??e("mask")[0];
document.boヽ(′ー`)ノdy.onmousedown = function(){
window.onmousemove = function(){
var cursor_(′▽?zhuān)?)X = event.clientX;
var cursor_Y = event.clientY;
if(cursor_X < def_left){
control_bar_cursor??.style??.left = 0;
}else if(cursor_X > contr??ol_bar.offsetWidtヽ(′ー`)ノh + def_left){
control_bar_curso?r.style.left = contr(╯°□°)╯ol_bar.o??ffsetWidth;
}else{
control_bar_curso??r.style.l( ?° ?? ?°)eft = cur??sor_X - def_left + "px";
}
//亮度比
vaˉ\_(ツ)_/ˉr proportion = parseInt(control_bar_cursor.offset(╥_╥)Left - def_left) / parseInt(control_bar.offsetWidth - 1);
control_bar_mask.style.width = pr??oportion * control( ?ヮ?)_bar.offsetWidth + "px";
mask.style.opacity = 1 - proportion;
};
window.onmouseup = function(){
window.onmousemov(′?_?`)e = null;
};
};
};
</script&g(′;ω;`)t;
</html>

1.將各個(gè)元素??的樣子寫(xiě)出來(lái)

這里為了方便好觀(guān)察給body添加了一個(gè)背景顏色

html

<div class='c??ontrol_bar'>
</div>
<div class='control_bar' style='border-bottom:3px solid #505151;'
id='control_bar_mask>
</div>(°□°);
<div class='( ?ヮ?)control_bar_cursor">
</div>

css

body{
background:back;
}
.control_bar{
height:200px;
width:5(′ω`*)00px;
border-bottom:3px solid #888888;
}
.control_bar_cursor{
height:25px;
width:8px;??
back(′?`)ground: #505151;
bord??er-radius:5px;
}

效果圖

2. 將各個(gè)元素疊到??一起

css??

body??{
background:black;
}
.control_bar{
height:200px;
width:500px;
borヽ(′ー`)ノder-bottom:3px solid #888888;

}
.c??ontrol_bar_curs??or{
height:25px;
width:8px;
background: #505151;
border-radius:5px;
margin-top:-12.5px;
position:relative;
top:0;
left:0;
}
.control_bar_cur??sor:hover{
background:white;
}
#control_bar_mask{
margin-top:-203px;
width:100pヾ(^-^)ノx;
}

這里為了顯示遮罩效果把遮罩層的(′ω`)div寬度設小了

3. 添加js

js

window.onload = function(){
var control_bar = document.getEleヽ(′?`)ノment(′ω`)sByClassName("control_bar")[0];
var control_bar_mask?? = document.getElementById("control_bar_mask");
var control_b??ar_cursor = document.get(/ω\)ElementsByClassName("c(′?`)ontrol_bar_cursor(′?`*)")[0];
var def_left = control_bar_cu??rsor.offsetLeft;
document.body.onmousedown = function(){
window.on??mousemove = functio(′Д` )n(){
var cursor_X = event.clientX;
var cursor_Y = event.clientY;
if(cursor_X < def_left){
control_??b??ar_cursor.style.left = 0;
}else if(cursor_X > control_bar.offsetWidth + def_left){
control_bar_cursor.style.left = control_bar.off??setWidth;
}else{
control_bar_cursor.style.left = cursor_X - def_left + "px";
}
var proportion = parseIn??t(control_bar_cursor.offsetLeft - def_left) / parseInt(control_bar.offsetWidth(′?ω?`) - 1);
control_ba(′▽?zhuān)?r_mask.st(′?_?`)yle.width = proportion * control_bar.offsetWidth + "px";
};
window.??onmouseup = function(??){
window.onmヽ(′ー`)ノousemove = null;
};
};
};

4. 添加一個(gè)mask用控制條來(lái)控制其透明度達到亮度調節效果

<div class='mask'></div>

.mask{
position:fixed;
bottom:0;
top:0;
left:0??;
right:0;
background:black;
z-index:-1;
}

window.onload = functi(′▽?zhuān)?on(){
var control_bar = document.getElementsByClassName("control_bar")[0];
var control_bar_mask = document.getElementById("c??ontrol_bar_mask");
var control_bar_cu(′▽?zhuān)?rsor = document.getElementsByClassName("c??ontrol_bar_cursor")[0];
var def_left = control_bar_cursor.offsetLeft;
var mask = document.getElementsByClassName("mask")[0];
document.body.onmouse??down = function(){
window.on??mousemove = func??tion(){
var(′?ω?`) cursor_X = event.clientX;
var cursor_Y = event.clientY;
if(cursor_X < def_left){
control_bar_cursor.style.left = 0;
}else if(c??ursor_X > control_bar.offsetWidth + def_left){
control_bar_cursor.style.left = control_b??ar.offsetWidth;
}el??se{
control_bar_cursor.style.left = cursor_X - def_??left + "px";
}
//亮度比
var proportion = parseInt(control_bar_cursor.offsetLeft(′_`) - def(°o°)_left) / parse(T_T)Int(control_ba??r.offsetWidth - 1);
control_bar_mask.style.width = proportion * contr??ol_bar.offsetWidth + "px";??
mask.style.opacity = 1 - pr(′;д;`)oportion;
};
window.onmouseup = functio??n(){
window.onmousemove = null;
};
};
};

總結

到此這篇關(guān)于HTML+CSS+JS模仿win10亮度調節效果的(′?`)示例代碼的文章就介紹到這了,更多相關(guān)html css win10 亮度調節內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!效果

模碼

來(lái)源:腳本之家

模碼

鏈接:https://www.jb51.net/web/728926.html┐(′ー`)┌

模碼
亚洲女同成aV人片在线观看|亚洲www啪成人一区二区麻豆|亚洲国产中日韩精品综合|亚洲国产成人精品一级片|亚洲无码在线视频免费 木兰县| 雷波县| 贵溪市| 宁都县| 二手房| 汉阴县| 新乡市| 张北县| 和平县| 河间市| 曲松县| 佳木斯市| 巫山县| 池州市| 江口县| 响水县| 兴仁县| 肥乡县| 溆浦县| 旬阳县| 北辰区| 卓资县| 开封县| 古丈县| 双牌县| 老河口市| 思南县| 古丈县| 京山县| 全南县| 淮南市| 台安县| 青冈县| 栾城县| 囊谦县| 德钦县| 南雄市| 望奎县| 永昌县| 纳雍县| 九台市| http://444 http://444 http://444 http://444 http://444 http://444