can be a little more complex, such as the left button keeps clicking, deepening, from light red to crimson, until it can not be deepened, right-click to achieve reverse operation!
can be a little more complex, such as the left button keeps clicking, deepening, from light red to crimson, until it can not be deepened, right-click to achieve reverse operation!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
div {
width: 300px;
height: 300px;
border: 2px solid -sharp000;
}
</style>
</head>
<body oncontextmenu="return false">
<div id='div' onmousedown='divClick(event)'></div>
<script>
var bgColor = ['00', '11', '22', '33', '44', '55', '66', '77', '88', '99', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff'];
var div = document.getElementById('div');
function changeBg(index) {
div.setAttribute('style', 'background-color: -sharp' + bgColor[index] + '0000')
div.setAttribute('data-index', index)
}
changeBg(0);
function divClick(event) {
var mouse = event.button
var index = div.getAttribute('data-index')
if(index == 0 && mouse == 0){
indexPP
}else if(index == (bgColor.length - 1) && mouse == 2){
index--
}else if (index > 0 && index < (bgColor.length - 1)) {
if (mouse == 0) {//
indexPP
} else if (mouse == 2) {//
index--
}
}
changeBg(index);
}
</script>
</body>
</html>
Color deepening change, you can start with color hexadecimal
all that is left is binding the mouse event to change the RGB value
you can use the filter. The specific code
const step = 1;
const div = document.getElementById('div');
let percent = 100;
function darken() {
percent += step;
div.style.filter = `brightness(${percent}%)`;
}
div.addEventListener('click', darken, false)
first of all, I will help you understand your specific principles of controlling rgba
.=> rgbr 0=>255
=> rgbgb 255=>0
<script>
window.onload=function(){
let num=255;
document.onclick=function(){
num--;
if(num<=0)num=0;
div1.style.background='rgb(255,'+num+','+num+')';
}
}
</script>
<div id="div1" style="width:50px; height:50px;"></div>
use hsv
Previous: On the Table problem of antd
Next: How to explain this phenomenon in JS? What is the principle?
now I am working on a game landing page with a 1200-high picture in the background, which is not high enough to fill the screen when placed on the phone. I hope to be able to force the horizontal screen when the phone is turned on. method I found: ...
...
the bosses react native web+H5 is very slow, android can t even click on the switch, and iOS is also very stuck. Is this a normal phenomenon or is there a problem with the code writing? If it is a normal phenomenon, we have a second solution is to bridg...
guys my younger brother put a child page on the iframe of the parent page (the domain of the father and son pages are different). The mechanism of the subpage is that after logging in, the token is stored in the cookie, and then the token is taken out...
are there any plug-in display sites at the front end? for example: iOS develops a website with components such as www.code4app.com. Is there a similar website at the front end? ...
an online link to a .json file, can you read the content with js? Can a link like such as http: 119.23.29.40 test.json read out the content directly with js? fileReader seems to only read the contents of blob objects or file objects, so how to read ...
problem description write an extension to customize the appearance of a website by moving a div this div itself does not respond, it is a response function added by the js file of the website so simply setting "run_at ": "document_end "document_...
how do I compress and merge all the js and css of the current directory to a single html file? our requirement is that only the html file is provided to the backend, and the backend is used for parsing. It will be troublesome to reference js css, and w...
know two latitude and longitude coordinate points, can you produce a parabola equation, want to draw a line dynamically. I m doing this on mapbox urgently request the boss to answer. ...
display order 1. Display the prompt box (the page is blank at this time) 2. HelloWorld is displayed normally after the click is determined <body> <script> document.write("<h1>HelloWorld< h1>"); do...
document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); Why does this code, the latter one, output the complete sentence "I am a flower " instead of emptying ...
only happens in Android, and scans the QR code with qq. You can jump to the page normally with ios version of qq, Android version of Wechat, and Android version of uc,. What is the reason for this? wow. ...
I have two component:User,Admin. Now, after I call const user= < User >, how can I tell whether user is an instance of User or Admin ...
for example, when calling the Alipay payment link, the H5 mobile page is blocked in the new window of the mobile browser. if (res.code === 1) { window.open(res.data.url) } url is the Alipay payment link to be adjusted. The new window can be opene...
<video loop="loop" muted autoplay="autoplay" style="width: 1920px;height: 598px;"> <source src=".. .. .. .. static video banner.mp4" type="video mp4"> < video> normal ...
rtrtrt do you have any bosses to share their experiences such as changing jobs ...