When I click the ECO button, both buttons move up by a few hundred pixels. The DARK mode button does not deliver the same result.
// script.js
function toggleDarkMode() {
console.log("Dark mode toggled"); // Check if the function is called
const body = document.querySelector('body');
body.classList.toggle('dark-mode');
}
function grayscale() {
// Toggle grayscale mode
var grayscaleModeActivated = document.body.classList.toggle("grayscale");
// Toggle CSS transitions for all elements
var elements = document.querySelectorAll("*");
elements.forEach(function(element) {
if (grayscaleModeActivated) {
element.style.transition = "none";
} else {
element.style.transition = "";
}
});
}
.buttons {
bottom: 0;
left: 0;
position: fixed;
padding: 50px;
}
<footer>
<div class="buttons">
<button class="mode" onclick="toggleDarkMode()">DARK</button>
<button class="eco" onclick="grayscale()">ECO</button>
</div>
</footer>
The issue seems to be related to the position property.