I am attempting to create a semi-transparent, solid background color on top of an <img>
tag, while still showing the original image underneath at the same ratio and size. Below is a snippet of the code I am working with (let me know if you need more information - the JS and CSS are inline and jQuery 3.6.0 is being used):
<div class="home-screen">
<img class="background" alt="Background Image" src="./assets/images/Desktop_Pictures/Catalina-min.jpg" />
</div>
div.home-screen {
height: 100%;
overflow: hidden;
}
div.home-screen img.background {
top: -50%;
margin-left: 0;
transform: translateX(0);
width: 100%;
position: fixed;
}
var isLaunchpadOpen = false;
function openLaunchpad() {
if (isLaunchpadOpen == false) {
$("div.home-screen")
.css("background-color", "rgb(211, 211, 211)")
.css("background-origin", "content-box")
.css("top", 0)
.css("position", "fixed");
$("div.home-screen img.background")
.css("background-blend-mode", "multiply")
.css("filter", "opacity(50%)");
isLaunchpadOpen = true;
} else if (isLaunchpadOpen == true) {
$("div.home-screen img.background")
.css("background-color", "none")
.css("filter", "opacity(100%)")
.css("background-blend-mode", "normal");
isLaunchpadOpen = false;
}
}
Please note that this code excerpt is specifically related to the issue I am encountering.