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

What is causing my server to mysteriously alter the style of index.html?

After setting up a node, express, react app, I realized that when express serves static content like my CSS file, the source of the index.html shows an additional style tag in the head section: <style type="text/css">* {}</style> I confirme ...

Achieving 100% height in a div container using flex while maintaining vertical centering

Struggling to center text and buttons using flexbox while keeping the columns equal? Setting column height as 100% can be a challenge. If you set the height to 100%, vertical alignment may no longer be centered. Avoid resorting to tables or JavaScript for ...

"Utilize Ajax to load PHP content and dynamically refresh a specific div

I have implemented an image uploading system, but now I want to incorporate a feature that allows users to rotate the uploaded images using Ajax. The challenge I'm facing is that if the session variable is lost during a full page update, I need to ens ...

The default value for an input of type date should be set to the current date

I am working on a project that involves an input field with the type of "date". I have implemented Materialize to provide a user-friendly date picker. My goal is to set the default value of this input field to the current date when it is initialized. Here ...

A pair of variables combined within a set of single quotation marks

After exploring numerous examples, I am still struggling to include a variable inside quotes. This situation seems unique and difficult to resolve. Take a look at the code snippet below: Var x='http://www.xyzftp/myservice/service1.svc' Var y=&a ...

using the GET method to transfer empty data

I am currently developing a basic search feature using php/sql with a primitive approach. Essentially, I am utilizing the GET method to send the form query across multiple fields in /search.php. This implies that the query will be sent in the following fo ...

Is there a way to prevent EasyTabs from automatically selecting the second tab?

I'm facing an issue with setting the default tab using easytabs. Currently, the second option is automatically selected as the default tab. Previously, I had successfully set the first tab (statistics) as the active tab but lost the file. Now, I am s ...

Exploring the functions of Safari input types: search, reset, and normalize

Is there a proper way to reset the appearance of a search input so that it resembles a text field in Safari? screenshot I'm experiencing an issue with Safari where there is unwanted padding on the left side of the search input that I can't seem ...

Replacing CSS conditional statements with jQuery

My CSS code is set to hide the #global-widget-base tag and display a tab #aside-expander when the browser width is less than 1200px. @media screen and (max-width: 1200px) { aside#global-widget-base { display: none !important; } #aside- ...

Having difficulty grasping the concept of toggleClass and jQuery selectors

I am struggling to understand the getLiveSearchUsers function in my JS file. Could someone please help me? I don't quite grasp what selector[0] is and what toggleClass is doing here. $.post("includes/handlers/ajax_search.php", {query:value, userLogge ...

Collapsible Span with Maximum Width in Unique Twitter Bootstrap

UPDATED If I assign a max-width value to the .container element, it disrupts the alignment of my spans. <div class="container" style="max-width:940px"> <div class="row"> <div class="span4" style="background-color:#F00">1</div& ...

Displaying a list of values in Angular using data retrieved from an Entity Framework query

Is there a way to populate a list (ul li) with data from an array that is populated through Entity Framework code? Currently, I am able to populate an option dropdown successfully using the following code: <select class="form-control" name="Search" ...

Configuring Node.js and express.js for my personal website to showcase my projects

I am new to node.js and I'm excited to implement it on my personal website as a way to start learning. I have successfully set up the node server, but I am struggling with setting up routing using express.js. All my files are typical static files like ...

The specified public directory could not be located

I'm trying to utilize Node.js with Express, and I recently found out about being able to specify a 'public' directory for serving static files. I've been attempting to place my bootstrap css/js files in the public directory, but I keep ...

Angular service provided by MetronicApp

I've been working on integrating Angular services with the Metronic App. This is how I defined my service: angular.module('MetronicApp').service('shaperService', ['$http', function ($http) { this.shapers = function(param ...

Exploring the application of URL parameters in HTML code

How can I use URL parameters retrieved with Javascript in my HTML? <script> var url_string = window.location.href; //window.location.href var url = new URL(url_string); var c = url.searchParams.get("name"); console.log(c); </script> I am tryi ...

Positioning elements absolutely within a Material-UI Grid component

Is there a way to align a Material-UI icon with text so that the lowest point of the icon starts exactly at the baseline? We are using Material-UI Grid layout. The issue we are facing is that if we align the icon using 'baseline', it appears too ...

Refresh your webpage automatically without the need to manually refresh after clicking a button using AJAX in HTML and PHP!

One issue I'm facing is that the page doesn't auto-refresh, although it loads when I manually refresh it. Below you can find my HTML and AJAX code along with its database details. The Trigger Button <?php $data = mysqli_ ...

I'm having trouble displaying the X's and O's in my tic tac toe JavaScript game. Any suggestions on how to resolve this issue?

After following a couple of online tutorials for the tic tac toe project, I encountered an error in both attempts. The X's and O's were not displaying even though all other features were working fine. Below are my codes for HTML, CSS, and JavaScr ...

Set Divs in Absolute Position Relative to Each Other

I need to create a simple navigation system using <div> elements as individual pages. The goal is to have "next" and "back" buttons that allow users to switch between these pages with a smooth fade-in and fade-out effect, all powered by jQuery. Howev ...