Is it possible to hover over an image that incorporates a gradient effect?

My website features various communication icons, including one for Instagram that I sourced from Font Awesome. I matched the color of this icon to the official Instagram logo using a Gradient effect. However, I am encountering an issue where the hover effect is not working as intended. I am unsure of how to resolve this problem.

footer {
  background-color: black;
  height: 120px;
}

footer a {
  display: flex;
  justify-content: center;
  font-size: 70px;
  padding: 20px;
  text-decoration: none !important;
}

.fa-instagram {
  background: #f09433;
  background: -moz-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  background: -webkit-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.fa-instagram:hover {
  color: hsla(181, 6%, 67%, 0.5);
}
<!DOCTYPE html>

<html>

<head>
  <link rel="stylesheet" type="text/css" href="main.css">


  <title>Website Title</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

</head>

<body>
  <footer>
    <a href="#" target="_blank">
      <i class="fab fa-instagram"></i>
    </a>
  </footer>
</body>

</html>

Answer №1

To achieve the desired effect, focus on modifying the background rather than the color. Ensure that only the background-image is altered to avoid conflicting with the background-clip property:

footer {
  background-color: black;
  height: 120px;
}

footer a {
  display: flex;
  justify-content: center;
  font-size: 70px;
  padding: 20px;
  text-decoration: none !important;
}

.fa-instagram {
  background-image: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.fa-instagram:hover {
  background-image: linear-gradient(hsla(181, 6%, 67%, 0.5), hsla(181, 6%, 67%, 0.5));
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<footer>
  <a href="#" target="_blank">
    <i class="fab fa-instagram"></i>
  </a>
</footer>

Answer №2

After experimenting and testing different approaches, I have arrived at the following solution. I opted to use background instead of color within your .fa-instagram:hover. Additionally, I included -webkit-background-clip: text;,

-webkit-text-fill-color: transparent;
, and added a transition:2s which can be removed if desired.

                
    footer {
        background-color: black;
        height: 120px;
    }

    footer a {
        display: flex;
        justify-content: center;
        font-size: 70px;
        padding: 20px;
        text-decoration: none !important;
    }

    .fa-instagram {
        background: #f09433; 
        background: -moz-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); 
        background: -webkit-linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
        background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .fa-instagram:hover {
        background: hsla(181, 6%, 67%, 0.5);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        transition:2s;
    }
 <head>
            <link rel="stylesheet" type="text/css" href="main.css">
            <title>Website Title</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

  </head>
        <footer>
               <a href="#" target="_blank"id="instagram">
                    <i class="fab fa-instagram" ></i>
               </a>
        </footer>    

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

Store a video file on your device's memory

Currently, I am storing simple strings in local storage. However, I am now facing the issue of wanting to save videos and images to local storage. Due to the limitations of localStorage supporting only strings, I am unsure of how to achieve this. If you h ...

Creating a complete webpage using HTML

Is there a method to load an HTML file and execute the embedded javascript to create a complete HTML page programmatically similar to how browsers do? Edit 1 - I am working on an application where I need to extract data from an HTML page on a remote websi ...

Clicking on the mat-icon-button with the matSuffix in the password field will always trigger a

Seeking assistance with implementing mat-icon-button matSuffix in Angular for a login page. This is my first time working with Angular and I am facing an issue with the password field. I have used mat-icon-button matSuffix, but whenever I click on the ico ...

Loading local HTML files in Vue 3 (Vite) iframe consistently defaults to displaying index.html

I'm relatively new to Vue and I'm attempting to embed a local HTML file into my Vue template using an iframe. Despite encountering related questions and solutions, none have resolved my issue so far. Here is what my component currently looks lik ...

Tips for animating input width as the size value changes during an ajax query transformation

This is my JavaScript code: function updatePriceDisplay() { $.ajax({ url:"query.php?currency=<?=$currencycode;?>" }).done(function(data) { $("value").attr("value", data).attr("size", data.length - 2); }); } updatePriceDi ...

Looking to prevent horizontal scrolling on smartphones in an HTML webview - how can I do this?

Currently, I am dealing with a webview and encountering some peculiar behavior. The overflow-x property is set to hidden, which works perfectly on browsers. However, when accessed on a mobile device, the overflow seems to be ignored completely. Here is t ...

Display the same DIV element across various HTML tabs

When two different tabs are clicked, I need to display a set of 10 Search Fields. Both tabs have the same fields, so instead of using separate DIVs, I want to use the same DIV and only change the AJAX REST End-Point based on the selected TAB. Can someone ...

Ensuring Bootstrap4 columns have a minimum height within a row

How can I adjust the right column in this image layout to crop the height and match it with the left column, aligning the bottoms of the images? This customization should only apply to lg+ screen sizes. An ideal solution using Bootstrap 4 without jQuery i ...

I attempted to implement the hover effect on a custom Tailwind CSS class I created, but unfortunately, it does not appear to be functioning as expected

For example: .btn {bg-blue-500 text-2 text-orange-300} .btn2 {bg-orange-500 text-2 text-blue-300} Attempted Solution: Edit: Apologies for the oversight in not including the code I was working with... it was late at night. < button className="btn ...

Can you explain the process for setting the css property text-fill-color in IE and Mozilla browsers, similar to how I set -webkit-text-fill-color for Webkit?

The color displays correctly in Chrome, but how can I make it work in both IE and FF? CSS #Grid td.note div.has-note i { -webkit-text-fill-color: #b4efa8; } ...

How to apply a class on button click using react.js

After spending a few weeks diving into React, I've got the hang of the basic syntax like props and states. However, I'm hitting a roadblock when it comes to connecting certain concepts, especially adding classes when a state changes. My current p ...

Having issues with AJAX and button submit while trying to upload a file using Flask

I've been attempting to incorporate a file upload feature (specifically a .csv file) using bootstrap, and then submit it by clicking on a button. I've experimented with various methods to implement the file upload functionality, but haven't ...

Retrieve the top 5 highest-selling items in a MySQL database

I am working with a MySQL database that has two tables: "SALES" and "USERS". The "SALES" table includes columns for id, product, code, quantity, amount, and who-sold-it (note: this is just an example field name). The "USERS" table includes columns for id, ...

steps for converting .SCSS files to .CSS in a project template

As a beginner developer, my expertise lies in HTML/CSS/JS and some fundamentals of their frameworks. Recently, I invested in this Template from template monster for a specific project () WHAT I NEED - My goal is to modify the primary theme color of the t ...

Retrieving data using a class in an AJAX form submission

I am attempting to use AJAX to submit an HTML form. Here is my HTML: <form class="lyrics"> <input type="text" value="" id="song" name="song"> <button type="submit" class="btn btn-info lirik">lyrics</button> </form> ...

Displaying Bootstrap 4 dropdown menu on hover

I've noticed that the dropdown menus in Bootstrap 4 are triggered by click by default, but for some reason, my menu is appearing on hover without any additional CSS or JS. This poses a problem for mobile development. I could create a jQuery solution, ...

Combining an anchor tag in HTML with PHP

I have attempted: <?php include("delete.php") ?> <?php .... .... .... if($result=mysql_query($sql)) { echo "<table><th>Id</th><th>Name</th><th>Description</th ...

Collapse the Bootstrap Menu upon selecting a Link

I am working on a side menu with an offcanvas display feature. The current functionality is such that when the button is clicked, the canvas pushes left and opens the menu. However, I want the menu to collapse and close automatically when a link is selecte ...

Tips for reducing the size of input-group-addon in Bootstrap

https://i.sstatic.net/V7ywZ.png <div class="time input-group"> <span class="input-group-addon" id="basic-addon4">Start Time </span> <timepicker [(ngModel)]="mytime" required></timepicker></di ...

Ensuring my website doesn't load within an iframe using PHP

I attempted to prevent my site from loading in other locations, but unfortunately, my efforts were unsuccessful even after using the following code. <?php header(X-Frame-Options: allow-from https://example.com); header(X-Frame-Options: deny); ?> Is ...