Using Font Awesome icons with CSS rotation causes compatibility issues

Having trouble getting the icons to rotate on hover? The transition effect is working smoothly, but it seems like the rotation functionality is not kicking in. Take a look at the code below and see if there are any mistakes:

@import 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css';
@import 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css';
.list-icon-wrapper {
  text-align: center;
}
.aticon i {
  border-radius: 50%;
  background: #5e8cfa;
  width: 160px;
  height: 160px;
  text-align: center;
  line-height: 100px;
  vertical-align: middle;
  padding: 30px;
  color: #fff;
  font-size: 60px;
}
.icon-wrapper:hover i {
  background: #fff;
  color: #5e8cfa;
  border: 1px solid #5e8cfa;
  transition: all 0.6s ease 0s;
  -webkit-transition: all 0.6s ease 0s;
  -moz-transition: all 0.6s ease 0s;
  -ms-transition: all 0.6s ease 0s;
  -o-transition: all 0.6s ease 0s;
  display: inline-block;
}
.aticon:hover .fa {
  transform: rotate(360deg);
  -webkit-transform: rotate(360deg);
  -o-transform: rotate(360deg);
  -ms-transform: rotate(360deg);
  -moz-transform: rotate(360deg);
}
.list-icon-wrapper .icon-wrapper p {
  padding: 0 5px;
  font-weight: 500;
  font-size: 18px;
  margin-top: 15px;
  color: #000;
  text-align: center;
  display: inline-block;
}
<div class="list-icon-wrapper">
  <div class="col-md-4">
    <div class="icon-wrapper">
      <span class="aticon">
                    <i class="fa fa-magnet"></i>
                </span>
      <p>Magnet</p>
    </div>
  </div>
  <div class="col-md-4">
    <div class="icon-wrapper">
      <span class="aticon">
                   <i class="fa fa-clock-o"></i>
                </span>
      <p>Clock</p>
    </div>
  </div>
</div>

Answer №1

It's interesting to note that FontAwesome uses the :before pseudo-element for rendering icons, rather than a background image. By targeting this element instead of the .fa element, you can customize the appearance of your icons easily. Check out the code snippet below to see how you can get started.

.icon-wrapper:hover .fa::before {
    background: #fff;
    color: #5e8cfa;
    border: 1px solid #5e8cfa;
    transition: all 0.6s ease 0s;
        -webkit-transition: all 0.6s ease 0s;
        -moz-transition: all 0.6s ease 0s;
        -ms-transition: all 0.6s ease 0s;
        -o-transition: all 0.6s ease 0s;
      display: inline-block;
}


.aticon:hover .fa::before {
    transform-origin: center;
      -ms-transform-origin: center;
      -webkit-transform-origin: center;
    transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -moz-transform: rotate(360deg);

}

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

Creating hanging indents using React JS

While most CSS code functions properly in React JS, I have encountered an issue with using text-indent to create a hanging indent. A hanging indent involves the first line of text being positioned to the left. In standard CSS, I would typically utilize tex ...

text/x-handlebars always missing in action

I'm currently working on my first app and I'm facing an issue with displaying handlebars scripts in the browser. Below is the HTML code: <!doctype html> <html> <head> <title>Random Presents</title> ...

IE8 experiencing issues with colgroup tag

Having trouble styling a data table with alternating row colors. 1) Need help applying alternating row style without having to add classes to each individual TD? 2) Colgroup works in IE8 but having alignment issues for specific columns (cols=A&SI Cap ...

What can I do to resolve the problem with td border

Check out my website over at browsethewebclean.com I've come across a peculiar issue with the borders and background color of some nested tables on my page. It seems that the border is not aligning properly and the background color goes beyond the im ...

PHP regular expression that identifies a specific HTML element

Similar Question: Effective ways to parse HTML using PHP I am currently creating a custom WordPress template for a client that requires a PHP function to extract specific HTML tags as defined by the function. For instance, if I input "div" into the f ...

When viewing the material-ui Chip component at normal zoom, a border outlines the element, but this border disappears when zoomed in or out, regardless of

Edit I have recently discovered a solution to the unusual problem I was facing with the material-ui Chip Component. By adding the line -webkit-appearance: none; to the root div for the Chip, the issue seems to resolve itself. However, this line is being a ...

Ensure that buttons are cropped when extending beyond the border of another DIV

My issue involves a main DIV with buttons contained within it. I am seeking a solution to ensure that the buttons are cut off at the edge of the DIV, similar to the concept illustrated in this image. In the image, the blue represents the body, the light gr ...

What is the best way to place a div within another div?

I am facing a challenge where I need to insert a new div within another div before all its existing contents. The issue is that the outer divs do not have unique IDs, only classes as selectors. Unfortunately, I do not have control over the generation of th ...

A dynamic and versatile solution for achieving uniform column heights across different web browsers using child elements

Get straight to the point. I'm looking for a solution to create a responsive two-column layout like the one shown in the image below. https://i.sstatic.net/mHhfc.png The width ratio of the .left and .right columns should always be 75/25% relative t ...

Issues with JavaScript and CSS functionality not functioning correctly as expected

There seems to be an issue with the order of HTML elements in the following code. When I place the div with the class thumb-bar before the full-img div, the JavaScript functions correctly. However, if I switch their positions, the JavaScript functionalitie ...

Updating Content in HTML Code Generated by JavaScript

My goal is to change the innerHTML of a div when it's clicked. I have an array of dynamically generated divs, and I want to target the specific table that the user clicks on. I attempted to set the IDs of the tables dynamically in my JavaScript code: ...

What is causing the malfunction of the JavaScript validation system?

I am having difficulty creating a validation system for a basic HTML form using JavaScript. The issue lies within the if statement, where it seems to return true if any one condition is satisfied even though I have used the && operator in the state ...

How can I overlay text on a background image smoothly?

Currently, I am in the process of developing a website optimized for mobile devices utilizing jQuery Mobile, HTML, and CSS. After successfully setting a background image, I encountered an issue regarding its stability while scrolling. Although the "backg ...

What could be causing this image to disregard the designated width value?

https://i.stack.imgur.com/bPH4t.png While working on my project with Next.js, I encountered an issue with the IconText component provided by Next.js. Even though I specified a width value for the image, it seems to be ignoring it. Below is the structure o ...

Issue with triggering Bootstrap Modal after its creation using jQuery dynamically

In SP2013, I am fetching items and dynamically constructing a modal using ajax from a list. The modal trigger ID is obtained dynamically from the ID column, and all items are created in the DOM, but the modal is not being triggered. There are no errors i ...

Ensure that a div with fluid width remains consistently centered within another div

I have a bunch of boxes filled with content. The number of boxes in each row varies depending on the width of the browser window. Is there a way to ensure that all the boxes are always horizontally centered on the page? For guidance, you can check out th ...

Switch a div to a computed location

I'm having trouble getting this code to animate a div to a calculated position. Can someone please help me troubleshoot? $(document).ready(function() { var is_Clicked = false; $("#togglebutton").click(function() { if (is_Cli ...

Is there a way to modify a component's CSS by using a global CSS class name in Angular?

We have implemented a system where a class on the html element determines whether the user is in dark or light mode of the application. <html class="dark-mode"></html> This class is dynamically added using Renderer2 in a service that detects ...

Different Ways to Make Custom Checkboxes Overlap with Labels in CSS

Hello everyone, I am currently diving into the world of CSS and HTML. My goal right now is to create a custom checkbox with a list of options. During my research, I stumbled upon an example on how to create custom checkboxes at this link. However, when imp ...