最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

HTML+CSS+JS模仿win10亮度調(diào)節(jié)效果的示例代碼

  發(fā)布時(shí)間:2020-06-04 15:39:18   作者: 南小樹(shù)   我要評(píng)論
這篇文章主要介紹了HTML+CSS+JS模仿win10亮度調(diào)節(jié)效果的示例代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

HTML+CSS+JS模仿win10亮度調(diào)節(jié)效果

代碼

<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>模仿win10的亮度調(diào)節(jié)</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:hover{
				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>
		<div class="control_bar" style="border-bottom:3px solid #505151;" id="control_bar_mask"></div>
		<div class="control_bar_cursor"></div>
	</body>
	<script>
		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 < def_left){
						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;
				};
			};
		};
	</script>
</html>

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

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

html

<div class="control_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:500px;
    border-bottom:3px solid #888888;
}
.control_bar_cursor{
    height:25px;
    width:8px;
    background: #505151;
    border-radius:5px;
}

效果圖

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

css

body{
    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;
}

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

3. 添加js

js

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;
    document.body.onmousedown = function(){
        window.onmousemove = function(){
            var cursor_X = event.clientX;
            var cursor_Y = event.clientY;
            if(cursor_X < def_left){
                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. 添加一個(gè)mask用控制條來(lái)控制其透明度達(dá)到亮度調(diào)節(jié)效果

<div class="mask"></div>
.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 < def_left){
                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;
        };
    };
};

總結(jié)

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

相關(guān)文章

  • HTML img標(biāo)簽和超鏈接標(biāo)簽詳細(xì)介紹

    文章介紹了HTML中img標(biāo)簽的使用,包括src屬性(指定圖片路徑)、相對(duì)/絕對(duì)路徑區(qū)別、alt替代文本、title提示、寬高控制及邊框設(shè)置等,本文主要給大家介紹HTML img標(biāo)簽和超鏈
    2025-06-20
  • HTML中meta標(biāo)簽的常見(jiàn)使用案例(示例詳解)

    HTML meta標(biāo)簽用于提供文檔元數(shù)據(jù),涵蓋字符編碼、SEO優(yōu)化、社交媒體集成、移動(dòng)設(shè)備適配、瀏覽器控制及安全隱私設(shè)置,優(yōu)化頁(yè)面顯示與搜索引擎索引,本文給大家介紹HTML中meta
    2025-06-20
  • HTML input 標(biāo)簽示例詳解

    input 標(biāo)簽主要用于接收用戶(hù)的輸入,隨 type 屬性值的不同,變換其具體功能,本文通過(guò)實(shí)例圖文并茂的形式給大家介紹HTML input 標(biāo)簽,感興趣的朋友一起看看吧
    2025-06-20
  • html 滾動(dòng)條滾動(dòng)過(guò)快會(huì)留下邊框線(xiàn)的解決方案

    這篇文章主要介紹了html 滾動(dòng)條滾動(dòng)過(guò)快會(huì)留下邊框線(xiàn)的解決方案,解決方法很簡(jiǎn)單,可以將 dialog 單獨(dú)拿出來(lái)別放在 transform 的子元素里,需要的朋友可以參考下
    2025-06-09
  • 在 HTML 文件中添加圖片的常用方法

    本文將介紹如何使用<img>標(biāo)簽在 HTML 中添加圖片,并展示一些常見(jiàn)的用法和技巧,通過(guò)本文的介紹,應(yīng)該掌握了在 HTML 中添加和調(diào)整圖片的基礎(chǔ)知識(shí),感興趣的朋友一起看
    2025-05-16
  • HTML 表格詳解(簡(jiǎn)單易懂較詳細(xì))

    HTML表格用于在網(wǎng)頁(yè)上展示數(shù)據(jù),通過(guò)標(biāo)簽及其相關(guān)標(biāo)簽來(lái)創(chuàng)建,表格由行和列組成,每一行包含一個(gè)或多個(gè)單元格,單元格可以包含文本、圖像、鏈接等元素,本文將詳細(xì)介紹HTML表格
    2025-03-12
  • 禁止HTML頁(yè)面滾動(dòng)的操作方法

    本文介紹了三種禁止HTML頁(yè)面滾動(dòng)的方法:通過(guò)CSS的overflow屬性、使用JavaScript的滾動(dòng)事件監(jiān)聽(tīng)器以及使用CSS的position:fixed屬性,每種方法都有其適用場(chǎng)景和優(yōu)缺點(diǎn),感興
    2025-02-24
  • 使用HTML和CSS實(shí)現(xiàn)文字鏤空效果的代碼示例

    在 Web 開(kāi)發(fā)中,文本的視覺(jué)效果是提升用戶(hù)體驗(yàn)的重要因素之一,通過(guò) CSS 技巧,我們可以創(chuàng)造出許多獨(dú)特的效果,例如文字鏤空效果,本文將帶你一步一步實(shí)現(xiàn)一個(gè)簡(jiǎn)單的文字鏤空
    2024-11-17
  • Html去除a標(biāo)簽的默認(rèn)樣式的操作代碼

    在Html中,a標(biāo)簽?zāi)J(rèn)的超鏈接樣式是藍(lán)色字體配下劃線(xiàn),這可能不滿(mǎn)足所有設(shè)計(jì)需求,如需去除這些默認(rèn)樣式,可以通過(guò)CSS來(lái)實(shí)現(xiàn),本文給大家介紹Html去除a標(biāo)簽的默認(rèn)樣式的操作代碼
    2024-09-25
  • HTML文本域如何設(shè)置為禁止用戶(hù)手動(dòng)拖動(dòng)

    在HTML中,可以通過(guò)設(shè)置CSS的resize屬性為none,來(lái)禁止用戶(hù)手動(dòng)拖動(dòng)文本域(textarea)的大小,這種方法簡(jiǎn)單有效,適用于大多數(shù)現(xiàn)代瀏覽器,但需要在老舊瀏覽器中進(jìn)行測(cè)試以確保
    2024-09-25

最新評(píng)論

山阴县| 克山县| 阿勒泰市| 比如县| 盐山县| 正定县| 时尚| 志丹县| 苍溪县| 金门县| 金山区| 杂多县| 仲巴县| 千阳县| 新蔡县| 克什克腾旗| 寿光市| 墨玉县| 元阳县| 讷河市| 资兴市| 焦作市| 古丈县| 威宁| 孝义市| 渝北区| 肇东市| 贵定县| 疏附县| 津南区| 凤台县| 香格里拉县| 安吉县| 兰西县| 调兵山市| 蚌埠市| 黔东| 神木县| 西城区| 逊克县| 黄龙县|