Creating a circular image with a vibrant color light effect that seamlessly runs across all browsers: What you need to know

Recently, I was working on a project involving this website that utilizes the Bootstrap framework. One interesting feature of the website is circle-shaped images that create a color light effect when hovered over. To achieve this, I decided to use the CSS property box-shadow as it wouldn't affect the image itself. Here's a snippet of the code:

HTML:

<div class="col-sm-3" id="af">
  <br/><br/><br/>
  <center>
  <img src="OnePicture.jpg" class="img-circle smallpic"/>
  </center>
  <!-- Additional content within the div -->
</div>

CSS:

.smallpic{
  max-width:100px;
  max-height: 100px;
  border: 3px solid transparent;

  /* Attempting to trigger GPU Acceleration*/

  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);        

  -webkit-transition: all 1s;
  -webkit-transition-timing-function: ease;
  transition: all 1s;
  transition-timing-function: ease;
}
#af:hover .smallpic{
    border: 3px solid #E3000E;
    -webkit-transform: translate3d(0,0,0);
    -moz-box-shadow:  0 0  500px 100px #E3000E;
    -webkit-box-shadow: 0 0  500px 100px #E3000E;
    box-shadow: 0 0  500px 100px #E3000E;
}

Despite successfully achieving the desired visual effect, it came to my attention that there is an issue with Webkit browsers like Google Chrome, where the effect doesn't render properly.

Here's how it appears in Google Chrome: link

While the code functions flawlessly on browsers such as Mozilla Firefox, Microsoft Edge, and Internet Explorer, the same cannot be said for Webkit-based ones including Google Chrome and Vivaldi. Are there alternative methods to achieve this effect across all browsers without relying on box-shadow?

Answer №1

However, achieving uniform behavior across all browsers is still possible with a few adjustments to your HTML and CSS code.

Below is an example of the modified HTML structure:

<div class="container primary">
  <div class="box"></div>
  <h2>Primary</h2>
</div>
<div class="container secondary">
  <div class="box"></div>
  <h2>Secondary</h2>
</div>
<div class="container tertiary">
  <div class="box"></div>
  <h2>Tertiary</h2>
</div>

And here is an example of the adjusted CSS:

.container {
  display: inline-block;
  position: relative;
  width: 300px;
  height: 300px;
}

.container:before {
  position: absolute;
  content: ' ';
  z-index: -1;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  transition: all 2s;
}

.secondary:before {
  background: radial-gradient(ellipse at center, rgba(0, 0, 255, .7) 10%, rgba(0, 0, 255, 0) 70%);
  opacity: 0;
}

.primary:before {
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, .7) 10%, rgba(255, 0, 0, 0) 70%);
  opacity: 0;
}

.tertiary:before {
  background: radial-gradient(ellipse at center, rgba(0, 255, 0, .7) 10%, rgba(0, 255, 0, 0) 70%);
  opacity: 0;
}

.container:hover:before {
  opacity: 1;
}

.box {
  margin: 100px auto 0;
  border: 4px solid red;
  border-radius: 50%;
  width: 100px;
  height: 100px;
}

.tertiary .box {
  border-color: rgb(0, 255, 0);
  background-color: rgba(0, 255, 0, .3);
}

.primary .box {
  border-color: rgb(255, 0, 0);
  background-color: rgba(255, 0, 0, .3);
}

.secondary .box {
  border-color: rgb(0, 0, 255);
  background-color: rgba(0, 0, 255, .3);
}

h2 {
  text-align: center;
}

You can view a live demonstration here

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

Trying to decide between using a Javascript or HTML5 PDF Editor?

I am in need of a solution that enables users to edit PDF files directly on an ASP.NET web page. This functionality is intended for creating templates and adding blocks/form fields to existing PDFs, complete with rulers and other necessary features. Desp ...

Creating new accounts with SQL in HTML code

I am working on a query to input any information entered into a form into the database. I have written some code, but I believe there is an issue with the query itself as I am unsure how to include variables in a SQL query. If anyone could assist me with t ...

What is the best way to ensure all my borders are uniform in size?

As I work on a JavaScript project that organizes words into blocks based on their size, I encountered an issue with inconsistent border thickness in certain areas. I'm using spans to contain each word, but I can't figure out how to make the borde ...

Tips for utilizing the nth-child selector to exclude hidden divs

I am facing an issue with displaying random blocks in rows. Each time a block falls into a new row, I want it to have a different style. However, when the user clicks on a button to hide certain blocks using display:none, the problem arises because the nth ...

Removing a row from an HTML table using JavaScript

I have a piece of JavaScript code that is responsible for managing an HTML table. One of the functionalities it needs to support is deleting a row from the table. Currently, I am using the following snippet of code to achieve row deletion: var rowToDele ...

How can I redirect a Spotify API request to save data directly to my local filesystem

I am developing a program for personal use that utilizes Spotify's API. My intention is not to make this software public, but rather to access and analyze my own playlist data. However, I am facing an issue with Spotify's authentication process. ...

Is there a way to capture and handle the data from XHR responses in casperjs?

Instead of constantly checking for changes in the html and using unreliable XPaths to extract data, I am interested in being able to extract information from XHR packets. It seems like a much more efficient way to retrieve the data displayed dynamically on ...

Adjusting the width of a nested iframe within two div containers

I am trying to dynamically change the width of a structure using JavaScript. Here is the current setup: <div id="HTMLGroupBox742928" class="HTMLGroupBox" style="width:1366px"> <div style="width:800px;"> <iframe id="notReliable_C ...

Tips for identifying a webpage and making class modifications based on it

I am working on a customized bar with 4 distinct parts. Each part corresponds to a different page on the website. I want each part of the bar to change color based on which page the user is currently browsing. For example, if the user is on page A, I want ...

What is the best way to implement an AppBar that fades in and out when scrolling within a div?

I'm trying to implement a Scrollable AppBar that hides on scroll down and reappears when scrolling up. Check out this image for reference To achieve this functionality, I am following the guidelines provided by Material-UI documentation export defa ...

Choosing <label> elements, while disregarding those <label> elements that include <input>

I need assistance with CSS rules to target only <label> elements that do not contain an <input> field inside of them. Is there a specific rule I can use for this? <label for="type">Regular Label</label> <label for="type"> ...

Ways to display certain JSON elements

I'm attempting to retrieve a specific part of a JSON file through AJAX and display it in an HTML div. I only want to show a certain object, like the temperature. Here is the AJAX code: $(function () { $.ajax({ 'url': 'http://ap ...

OptinMonster's innovative feature - the Pardot form with an inline button

Having trouble integrating an HTML Pardot form into OptinMonster's floating footer option. I'm looking to align all three fields inline, along with the button. Can anyone assist me in placing the button inline with the fields? HTML: <fo ...

Show the first letter of the first name using HTML

Is there a way to display the first letter of the first name followed by a period, a space, and then show the last name in asp/html/vb? ...

Looking to create a pop-up using javascript, css, or jQuery?

When visiting digg.com and clicking the login button, a sleek in-screen popup appears to input user data. I'm curious about the best way to achieve this on my own site. It is built with RoR and includes some Javascript elements. Searching for "javasc ...

Tips for increasing the font size using html and css?

I am encountering an issue with my HTML code: <div class="a"><font size="40"><font color="black">A</font></font></div> No matter what I try, I cannot seem to increase the font-size. Even adjusting the value in the co ...

Tips for relocating a CSS button

I have designed two buttons using css and I am looking to align them below the title "forecast customer activity". Due to extensive styling in css, the code might appear lengthy. Requesting assistance with a solution after reviewing the following code snip ...

Utilizing PHP to fetch data from a separate webpage

This is a question that has sparked my curiosity. I am not facing any particular issue that requires an immediate solution nor do I possess the knowledge on how to achieve it. I have been contemplating whether it is feasible to utilize PHP for fetching co ...

"Combining background images with javascript can result in displaying visual elements

Hello! I am in need of assistance with a CSS + Javascript fog effect that I have developed. It is functioning properly on Firefox, Opera, and Chrome but encountering issues on IE and Edge browsers. The effect involves moving two background images within a ...