the problem here that I covered the entire content with nighmode switcher "<div…
- User
the problem here that I covered the entire content with nighmode switcher "" but I want this thing to be able to activate on mouse click and at the same time be able to select text behind it and after when it disabled.:
header { background-color: #4CAF50; color: #FFF; padding: 16px 0; text-align: center; position: relative; z-index: 0;
}
h1 { margin: 0 auto; display: flex; justify-content: space-between; align-items: center; font-size: 18px; width: 90%; height: 1%; }
.left, .right { position: relative; }
.left::before, .right::before { content: ‘’; position: absolute; top: 50%; border-bottom: 1px dashed #FFF; width: 40%; }
.left::before { right: 100%; margin-right: 20px; }
.right::before { left: 100%; margin-left: 20px; }
.flags-container { position: fixed; top: 0; left: 0; right: 0; padding: 3px 0; background-color: white; display: flex; justify-content: center; align-items: center; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); z-index: 1; }
.flag-radio { display: none; }
.flag-label { cursor: pointer; margin: 0 10px; transition: 0.3s; opacity: 0.6; font-size: 24px; }
.flag-label:hover { opacity: 1; }
.language-option { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: none; justify-content: center; align-items: center; padding-top: 50px; }
#english-flag:checked ~ #english, #hindi-flag:checked ~ #hindi, #hebrew-flag:checked ~ #hebrew, #chinese-flag:checked ~ #chinese, #french-flag:checked ~ #french, #spanish-flag:checked ~ #spanish { display: block; }
.switch-container { position: relative; --padding: 20px; user-select: text; z-index: 21; width: 100%; height: 100%; top:100px; }
.switch-container input[type="checkbox"] { width: 18px; height: 18px; pointer-events: all; z-index: 21;
}
.switch-container label:before { content: ""; position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 0.3s ease-out; pointer-events: none; /* <--here! */ z-index: 21;
}
.switch-container input[type="checkbox"]:checked ~ label:before { opacity: 1; pointer-events: all; z-index: 21; top: 0; left: 0; width: 100%; height: 100%; }
- Assistant
To make the night mode switcher activate on mouse click, you can add an event listener to the checkbox input like this:
let switchCheckbox = document.getElementById("switch"); let switchContainer = document.querySelector(".switch-container"); switchCheckbox.addEventListener("click", function(){ switchContainer.classList.toggle("night-mode"); });This will toggle the "night-mode" class on the switch container when the checkbox is clicked. You can also add some styles to this class to change the appearance of the page in night mode. To enable text selection behind the switch, you can set
pointer-events: noneon the label element in CSS:.switch-container label { pointer-events: none; }This will allow mouse events to pass through the label element, so you can still select text behind it. When the night mode is enabled, you can set
pointer-events: allto make the switch clickable again. - User
css and html only
- Assistant
Okay, here's a CSS and HTML solution to your problem:
First, wrap your entire content inside a container div with class "wrapper":
- User
and can you integrate it into original for testing?
- Assistant