Challenges with the efficiency of hover effects

I have a div with a background image and inside that div, there is a component called Hero. I want to add a simple hover effect on a div with a className newBigButton. However, the transition is laggy when the background image is present. Here's the code:

      <div
        className="hero-section"
        style={{
          flex: 1,
          display: "flex",
          backgroundImage: bg ? `url(${bg})` : "",
          backgroundPosition: " 60% center",
        }}
      >
        <Hero />
      </div>

Part of the Hero component code:

  <div style={{marginTop: "15vh"}} className="d-flex w-100 flex-column justify-content-center align-items-center">
    <div style={{gap: "20vh"}} className="d-flex ">
      <div className={styles.newBigButton}>BESOIN IMMÉDIAT</div>

      <div className={styles.newBigButton}>PROJET À VENIR</div>
    </div>

    <div style={{marginTop: "8vh"}} className={styles.newBlueButton}>Demander une démo</div>
  </div>

The CSS for New Big Button:

.newBigButton {
  color: #2863a9;
  background-color: #fff;
  border-radius: 10px;
  border: 2px solid #2863a9;
  padding: 3.5vh 2vh;
  font-weight: 800;
  cursor: pointer;
  transition: 0.1s linear;
}

.newBigButton:hover{
  background-color: #2863a9;
  color: #fff;
}

Answer №1

If you're noticing a laggy transition effect in your hero-section div with a background image, it's likely because of the browser's rendering performance, especially if the image is large or the structure is complex.

Large images can slow down loading and rendering times, leading to delays in CSS transitions.

To improve this, consider optimizing the background image.

Make sure your background image is optimized for the web by reducing its size and resolution without compromising quality. This will help the image load faster and enhance overall performance.

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

Using Stripe Elements to validate inputs before submitting the form

In the process of handling payments, I am implementing react stripe elements to create a payment flow. While using the onChange prop to display live error messages as the user types in their information, I also want these errors to be visible once they cli ...

TypeScript encountered an error with code TS2305, stating that the module "constants" does not have any exported members

My Vite + React + TypeScript application has the following structure: src constants a.ts b.ts index.ts components Comp.tsx tsconfig file with "baseUrl": "src" The content of a.ts is as follows: export const ARRAY = ...

Encountering a classnotfound exception with JSP JDBC SERVLET, but all code appears to be

index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> < ...

The checkboxes seem to be malfunctioning following an ajax request

I've been attempting to utilize ajax to load data, but for some reason the checkboxes aren't functioning. Below is the HTML I'm trying to load via ajax: <div class="mt-checkbox-list" > <?php foreach($product_offerings as $row){ $c ...

Using a CSS gradient with a variable in React.js - A guide to implementation

Looking to incorporate the following CSS property into the Navlink component. In the CSS file, the property is usually written like this using gradient. .ele { background-image: linear-gradient(45deg, #808080 25%, transparent 25%), li ...

CSS reinitialization for the HTML5 button element

Is there a way to reset the HTML5 button tag so that it behaves consistently across all browsers? Currently experiencing issues with IE9 going haywire when trying to style the button tag. I am aware of using display:block; but what other solutions exist.. ...

Exploring the concept of mapping and looping within a simple React component

For a component that is used by multiple data sets but displays the same information, should it accept only native data types or an array of objects? The dilemma arises from the fact that each table has different data properties. <ScrollView> {lis ...

Convert HTML content to a PDF file with Java

Welcome to the community! My project involves extracting data from a website containing information on various chemical substances and converting it into a PDF while preserving the original HTML formatting, including CSS styles. For example, here is a li ...

In order to design a v-btn-toggle with vertically aligned buttons, rather than horizontally

I'm currently in the process of developing a quiz using VueJS and Vuetify. My challenge lies in organizing the answer options vertically for the user to select. I attempted to utilize the v-btn-toggle component, but encountered an issue where the butt ...

Getting a portion of a href link in Java using Selenium

I am looking to compare the current URL in Google Chrome with a specific href link that contains two URLs. I need to extract the first link from this specific href link: click here <a href="http://pubcontentqa.perion.com/dz2/html/interstitial.html?http ...

The transfer with ipcRenderer.postMessage in Electron has encountered an invalid value

I encountered an issue with the message Invalid value for transfer when attempting to utilize the message-ports-reply-streams feature for the first time. In my preload.js file, I defined the following api: contextBridge.exposeInMainWorld( "api&quo ...

CSS Grid with dynamically changing number of rows set to "auto", while ensuring one row always has a fixed size of "1fr"

Currently, I am experimenting with a CSS grid-based frontend and have encountered a specific requirement that keeps repeating itself in various parts of the frontend: A grid with a dynamic number of rows. Each row should be of variable size (auto). The f ...

What is the best way to dynamically adjust the select option?

I need help with handling JSON objects: [ { id: "IYQss7JM8LS4lXHV6twn", address: "US", orderStatus: "On the way", }, ]; My goal is to create a select option for the order status. If the current status is "On ...

Halt the adhesion of the Bootstrap column when it hits the div section

I have a simple bootstrap row containing two columns: <div class="row"> <div class="col-xs-7"> <p>Walking together</p> </div> <div class="col-xs-5" id="stay"> <p>Joyful journey</p> </div ...

Adaptable design tailored for smartphones

When it comes to developing mobile websites for various platforms such as iPhone 3 and 4, Android, Blackberry Torch, etc., I usually find myself needing to slice images based on the specific platform. The challenge arises from constantly having to slice im ...

When clicking, expand the li element to 100% width and move the other siblings aside

I'm looking to arrange li elements in multiple columns with flexibility. https://i.sstatic.net/HJCZu.png <ul> <li class="yellow"> Yellow Block </li> <li class="red"> Red Block ...

The background image fails to display properly on the server in Next.js

Hello, I'm currently using NextJs and I have a challenge. I want to set a background image on the body element that is rendered server-side. Below you'll find my code snippets: First, here is my App.js: import BodyStyle from '@components/Bo ...

Issues with alignment within Bootstrap grid system

I have three unique "cards" that I want to display horizontally and center on the page without using the bootstrap card class. Currently, I am attempting to assign each of them a width of .col-lg-4 within an outer div set to full width. However, they are s ...

Clicking on the react router does not trigger any action

I'm currently developing a Pokemon list app similar to the one in this tutorial: https://www.youtube.com/watch?v=XehSJF85F38&t=5904s However, I've encountered an issue where my routes are not functioning properly, even though I followed the ...

Jenkins encountered an issue with the React build process, generating the following error message: "build-js" exited with code

Currently in the process of transferring my local Jenkins to a new EC2 instance and while moving the UI build pipeline, I encountered an error: ERROR: "build-js" exited with 1. This same error occurred on the existing Jenkins server but was res ...