Animated gradient background with translucent elements superimposed on top

Looking for help on animating a color gradient behind an image with transparent elements so that only the transparent parts of the image change colors. Currently, the animation is covering the entire image as if it's in front of the PNG flower image rather than behind it. Any assistance would be greatly appreciated. Thank you!

HTML

<body>
    <h1>
        <div class="shimmer"></div>
        <img src="https://i.imgur.com/XYoiBsw.png" />
    </h1>
</body>

CSS

h1
{
display: inline-block;
overflow: hidden;
position: relative;
}

h1 a, h1 div.shimmer
{
height: 100%;
width: 100%;
position: absolute;
top: 0px;

}
h1 a
{
display: block;
z-index: 3;
}
h1 a span { display: none; }

h1 div.shimmer
{
background-image: linear-gradient(110deg, rgba(109,246,217,0.60) 25%, rgba(209,246,217,0.70) 37%, rgba(255,255,255,0.98) 50%, rgba(246,176,45,0.70) 85%, rgba(65,226,135,0.60) 99%); /* W3C */
background-repeat: repeat-y;
background-size: 100% 100%;
left: -100%;
z-index: 2;
}
h1:hover div.shimmer
{
left: 100%;
transition: left 1.35s linear;
}

Answer №1

Modify h1 div.shimmer {z-index: 2;} to z-index: -1; :

h1
{
display: inline-block;
overflow: hidden;
position: relative;
}

h1 a, h1 div.shimmer
{
height: 100%;
width: 100%;
position: absolute;
top: 0px;

}

h1 a span { display: none; }

h1 div.shimmer
{
background-image: linear-gradient(110deg, rgba(109,246,217,0.60) 25%, rgba(209,246,217,0.70) 37%, rgba(255,255,255,0.98) 50%, rgba(246,176,45,0.70) 85%, rgba(65,226,135,0.60) 99%); /* W3C */
background-repeat: repeat-y;
background-size: 100% 100%;
left: -100%;
z-index: -1;
}
h1:hover div.shimmer
{
left: 100%;
transition: left 1.35s linear;
}
<body>
    <h1>
        <div class="shimmer"></div>
        <img src="https://i.imgur.com/XYoiBsw.png" />
    </h1>
</body>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Turn off the annoying right-click context menu in Firefox

I'm currently working on an HTML 5 game that requires the player to use right click for control. To disable the right click context menu, I have used the following code: <body oncontextmenu="return(false);"> However, I discovered that in Fire ...

Create a sleek 2-column design featuring a bonus scroll bar exclusively using CSS styling

In my current project, I have a unique challenge. I am working with a list of flattened div elements and unfortunately, I am unable to edit the HTML markup to add any structures. The first div in the list is quite long, and I would like to place it in a se ...

Tips for closing a sidecart by clicking outside of it

I am currently exploring how to implement the functionality of closing my sidecart when I click outside of it. Below is the script I am using: const toggler = document.getElementById('menu-toggle'); const cartWrapper = document.getElementById( ...

Move the items downwards to occupy any empty space vertically

Just a quick overview of the code I'm working with (I am using Material UI in React). This container is meant to hold chat messages exclusively. const ChatContainer = ({ chatMessages }) => { const classes = useStyles(); return ( <Paper ...

The cursor seems to be malfunctioning and not displaying correctly

Need help changing the cursor on my website. The cursor I want to use is: (data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFQklEQVRYCe2XW2wUVRjH/3u/lZZuWxEEW2kJVyumJUYexAupiRgiYlIl8fKKEiMxsQnKC28mXghGCVVo0ojXBwQaJcHEG1i1LYsoS1tuDV0oh ...

An unusual html element

During a recent exploration of a website's code using the inspect tool, I stumbled upon a tag that was completely unfamiliar to me. <gblockquote></gblockquote> I've come across a blockquote before, but never a gblockquote. Interest ...

JavaScript Number Conversion with parseInt()

Struggling to execute a calculation that fills a text box based on an onblur event. Unfortunately, I keep getting NaN as the result. Since I am not very familiar with JavaScript, any guidance will be greatly appreciated. Please note that I am mainly focus ...

MUI Grid - justify content to the right

I'm new to utilizing the MUI Grid system and I am currently trying to accomplish a simple task of aligning my 'Cancel' and 'Save' buttons all the way to the right on the screen. Despite browsing through various posts and documentat ...

Ensure the HTML table automatically adjusts its size to accommodate all contents without any text wrapping

I currently have a table that spans 100% of the window width. Here is a simplified structure of the table (CSS/styles removed for clarity) <table> <tbody> <tr> <td>Row ID</td> <td> ...

Switching between a secondary menu using ClassieJS or jQuery?

Currently, the code is configured to toggle the same menu for every icon. To see my current progress, you can check out this fiddle: http://jsfiddle.net/2Lyttauv/ My goal is to have a unique menu for each individual icon. I began by creating the followi ...

Tips for saving JavaScript results to a form

Hey there! I'm looking to figure out how to save a JavaScript calculation within a form instead of just displaying an alert or outputting it on another page. Below is the JavaScript code I have for calculating prices. <script type="text/javascript ...

Tips on wrapping div elements while maintaining equal width in different screen sizes using @media queries

Does anyone have a solution for wrapping divs using @media screen while maintaining equal width on all divs? I've tried using float and inline-block, but can't seem to achieve consistent justified widths. While table-cells maintain equal field wi ...

Clear navigation bar on top of a backdrop picture

I am currently exploring the most effective method to place my hero/background image behind a transparent Bootstrap 4 navbar. Some have suggested applying the background image to the body of the page, but I specifically want the background image only on th ...

Alternate. (individually)

Issue with Running Program I've been struggling to get my program to run correctly. The task at hand is to have the program display only one question at a time. But no matter what I try, clicking on all questions displays all the answers simultaneous ...

Application of id missing on all buttons in Bootstrap tour template

I'm having an issue with applying a new id to the next button in a Bootstrap tour template. I added the id to the button, but it only seems to work for the first stage and not the subsequent ones. Can anyone provide insight into why this might be happ ...

Saving data in HTML using PHP and then downloading it

Currently, I am tackling a project involving a website that is connected using PHP. The main function of the PHP script is to modify an HTML file stored on the server and then allow the user to download it. I attempted to use PHP DOM for this task but unf ...

Browsing through database images and aligning them with CSS to the center

I am working on creating a single row of three centered images inside a div. Both the images and the div itself need to be centered on the page. The images will be contained within the div, here's what I have so far: HTML/PHP <?php $resul ...

Efficiently loading Angular views with lazy loading techniques

I am currently working on a calculator website powered by Angular. This single-page site is fully responsive and divided into 7 sections, each featuring different calculators based on user preferences. To improve loading time, I am interested in implementi ...

Why is it that aligning items in a row doesn't seem to function properly when I apply a custom class to a container-fluid in Bootstrap 4?

Recently, I started delving into the world of front end development. After mastering the basics of HTML5 and CSS3, I ventured into Bootstrap 4. My current project involves creating a replica of the Facebook login page. To achieve a full-width design, I uti ...

Decreasing the Height of Modal Header with Tabs in Bootstrap 4

Working with Bootstrap 4, I've set up a Modal Dialog with Tabs. However, I'm facing an issue with the height of the Modal Header containing the Tabs, and I need to decrease it. Here's the current appearance: Header - Tall Desired appearanc ...