The transformation rotation applied in CSS must not have any impact on the styling of my span and paragraph

Snippet:

.details-section{
  background-color: rgb(83, 83, 83);
  height: 200px;
}

.icon-container{
  border: 2px solid #c49b63;
  width: 90px;
  height: 90px;
  transition: 0.5s ease;
  
}

.box i{
  font-size: 60px;
  color: black;
  margin-top: 13px;
  transition: 0.5s ease;
}

.icon-container:hover{
  transform: rotate(135deg);
  background-color: #c49b63;
}

.icon-container:hover i{
  transform: rotate(-135deg);
}

.counter-box {
  display: block;
  text-align: center
}
.counter {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: #666;
  line-height: 28px
}

.counter-box p {
  margin: 5px 0 0;
  padding: 0;
  color: #909090;
  font-size: 18px;
  font-weight: 500
}
<div class="container-fluid details-section">
  <div class="row justify-content-center h-100">
   <div class="col-xl-2 my-auto box text-center">
     <div class="icon-container">
       <i class="fa fa-thumbs-o-up"></i>
       <div class="counter-box">
         <span class="counter">3275</span>
          <p>Registered Members</p>
        </div>
      </div>
  </div>
  <div class="col-xl-2 my-auto box text-center">
     <div class="icon-container">
       <i class="fa fa-check"></i>
      </div>
  </div>
  <div class="col-xl-2 my-auto box text-center">
     <div class="icon-container">
       <i class="fa fa-shopping-cart"></i>
      </div>
  </div>
  </div>
</div>

When hovering over the border or icon in the snippet provided, they rotate along with the span and paragraph tags. I would like to avoid this rotation affecting the counter-box division. My goal is for the counter-box to remain stable during the rotation transitions. Any assistance would be greatly appreciated. Thank you.

Answer №1

I made some updates to the CSS code, please review

.details-section{
  background-color: rgb(83, 83, 83);
  height: 200px;
}

.icon-container{
    width: 90px;
    height: 90px;
    position: relative;
  
}
.icon-container:before {
    content: '';
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    transition: 0.5s ease;
    border: 2px solid #c49b63;
    }
.icon-container:hover:before {
    transform: rotate(135deg);
    background: #c49b63;
 }

.box i{
  font-size: 60px;
  color: black;
  margin-top: 13px;
  position: relative;
  /* transition: 0.5s ease; */
}

/* .icon-container:hover{
  transform: rotate(135deg);
  background-color: #c49b63;
} */

/* .icon-container:hover i{
  transform: rotate(-135deg);
} */

.counter-box {
  display: block;
  text-align: center;
  position:relative;
}
.counter {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: #666;
  line-height: 28px
}

.counter-box p {
  margin: 5px 0 0;
  padding: 0;
  color: #909090;
  font-size: 18px;
  font-weight: 500
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet"/>
<div class="container-fluid details-section">
  <div class="row justify-content-center h-100">
   <div class="col-xl-2 my-auto box text-center">
     <div class="icon-container">
       <i class="fa fa-thumbs-o-up"></i>
       <div class="counter-box">
         <span class="counter">3275</span>
          <p>Registered Members</p>
        </div>
      </div>
  </div>
  <div class="col-xl-2 my-auto box text-center">
     <div class="icon-container">
       <i class="fa fa-check"></i>
      </div>
  </div>
  <div class="col-xl-2 my-auto box text-center">
     <div class="icon-container">
       <i class="fa fa-shopping-cart"></i>
      </div>
  </div>
  </div>
</div>

Answer №2

To create a rotating effect on an element, you can utilize the pseudo-class ::after within the wrapper element. This will allow you to define the styles you want for the element and then rotate it upon hovering over the wrapper. The following code demonstrates this technique:

.wrapper {
  position: relative;
}

.wrapper::after {
  content: "";
  position: absolute;
  border: 10px solid crimson;
  width: 500px;
  height: 500px;
}

.wrapper:hover::after {
  transform: rotate(-180deg);
  transition: .3s;
}

.sample {
  position: absolute;
  width: 500px;
  height: 500px;
  z-index: 1;
}

<div className="wrapper">
  <div className="sample">
    <p>some content</p>
  </div>
</div>

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 the best way to ensure that less2css compiles all files after saving just one less file?

In my project, I have a style.less file that imports "page.less". Whenever there is a change made to page.less, I find myself having to go back to the style.less file and save it in order for less2css to compile and apply the changes. If not, the changes ...

Having troubles with your jQuery script on Internet Explorer?

I am facing an issue with my script. It is located in an external file and called at the beginning of my HTML page. The script involves an Ajax request that constantly checks a database for updates. When an update is detected, it triggers a specific functi ...

Error: Attempting to use hooks outside the scope of a function component in react-native. Hooks can only be called within the body of a

Oops! An error occurred: Invalid hook call. Hooks can only be called inside the body of a function component. There are several reasons why this might have happened: You could have incompatible versions of React and the renderer (e.g., React DOM) Your cod ...

Error message: Unexpected token "(" in the asynchronous aspect of Meteor

Currently running meteor version 1.5.1, I am facing a bug while attempting to import an npm module (kraken-api) on the server side: import KrakenClient from 'kraken-api'; > W20170726-22:02:48.177(2)? (STDERR) packages/modules.js:677 ...

Preventing Angular $rootElement.on('click') from affecting ReactJS anchor tag interactions

Running both AngularJS and ReactJS on the same page has caused an issue for me. Whenever I click on a ReactJS <a> tag, Angular's $rootElement.on('click) event is triggered and the page redirects. I need to perform some functionality in Re ...

Tips on scrolling down to find the text you're looking for

I attempted to scroll downwards in my application's window using the following JavaScript code: ((JavascriptExecutor) driver).executeScript("windows.scrollBy(0,500)"); Additionally, I tried to ensure a specific element is in view with this script: ...

Stack 2 cards inside a DIV vertically using Materialize CSS

My form and table are currently positioned side by side in 2 columns: https://i.sstatic.net/croh3.png The layout of this form/table is built using datatable + materialize CSS. I am looking to place the Form and table within a div to ensure that the bott ...

What is the best way to incorporate the same partial multiple times with varying content in Nunjucks?

I'm working on several page templates that require the same partial to be included multiple times but with different content each time. I explored looping this, but the order might not always be sequential. Here's an example of how my page templ ...

Transitioning from the older version of Angular (1.0.8) to the newer version (1.2.0

Transitioning to the latest production version of Angular has been quite challenging for me. I have meticulously followed the migration guidelines, focusing mainly on the underscore prefix \ private attributes section that seemed relevant to my situa ...

What is a way to retain the value of a variable after a request, while starting off with a different value on the initial load?

In my Flask application, users have the option to choose a specific time period with a start date and an end date. When the page initially loads, I want the start date to default to the first day of the current month and the end date to be the current day. ...

Trigger price update in jquery based on radio or checkbox selection and specific conditions

https://i.sstatic.net/OIvgF.png In my product form, I have implemented a feature where selecting the "product type" and "product size" will update the price. However, if the user changes the product type after selecting the size, the price does not update ...

What is the best way to incorporate audio playback while browsing files on an HTML5 webpage with TypeScript?

<input type="file" id="soundUrl" (change)="onAudioPlay()" /> <audio id="sound" controls></audio> This is the HTML code I'm working with, and I'm looking to trigger audio playback after a user selects an MP3 file using TypeScrip ...

When implementing JWT for route authentication, the webpage remains frozen in one spot

Currently, I am in the process of making modifications to a project. The front-end is built using Vue 2.0 and the back-end utilizes Node.js Express. To ensure security, I have implemented the JWT approach by requiring authentication for all pages except th ...

My current array is arr=[1,2,3,4]. I recently added an element to it using arr.push(5). Now I want to rearrange the array to be [5,4,3,2,1]. Any suggestions on how to achieve this

I currently have an array in the following format: var arr = [1,2,3,4] // Add another element to the array arr.push(5) // Now, arr = [1,2,3,4,5] I want to print my array as The elements in the array arr are: 5,1,2,3,4 When I use Arr.reverse(), it retu ...

Discovering elements that are currently visible in an Angular list

Suppose there is a variable named users which represents an array We have the following ng-repeat statement: ng-repeat="user in users | filterUser: searchUser: assignedUsers: selectedDivision" After filtering the users using searchUser and selectedDivis ...

Automatically submitting the form

Is there a way to automatically submit a form once 4 numbers are inputted into the field without having to press enter or click submit? <form action="send.php" method="POST"> <input type="number" maxlength="4"> </form> I have a basic ...

Can you explain the concept of asynchronous in the context of Ajax?

Can you explain the concept of Asynchronous in Ajax? Additionally, how does Ajax determine when to retrieve data without constantly polling the server? ...

How can we integrate Cordova plugins into Vue-Cordova framework?

Looking to integrate Vue-Cordova with Cordova-plugin-file-opener2 to open PDF files within iOS/Android applications. In the Vue-Cordova setup, plugins related to the device are defined on the data property of the App vue instance: data: function () { ...

Is there a way to decrease the size of the content within this iFrame?

Is there a way to display 6 cameras on a single webpage without them taking up the entire screen within iframe windows? Can the content be shrunken to fit the iframe window? <!doctype html> <html> <head> <meta charset="utf-8"> &l ...

Incorporating a Streamlit Application into an Established React.js Project via an iFrame

I am in the process of incorporating a Streamlit app into my existing React.js application to take advantage of its data analysis and visualization features. Can this integration be accomplished using an iFrame? Has anyone successfully embedded a Streamlit ...