The height transition feature does not seem to be functioning correctly within the React project

When I display cards, hovering over the card will increase its height and reveal the description. The following is my CSS and code, and I am looking to add a transition effect while adjusting the height:

<div className="icon-box">
                    <div className="icon">
                      <img
                        src={item.compliance_logo}
                        style={{ height: "100%", width: "110%" }}
                        alt="logo"
                      />
                    </div>
                    <h3>
                      <a style={{ color: "#000080" }}>{item.compliance_name}</a>
                    </h3>
                    <p style={{ fontSize: "12px" }}>
                      {item.compliance_description}
                    </p>
                  </div>

The corresponding CSS is as follows:

.icon-box {
  padding: 30px;
  background: #fff;
  box-shadow: 0px 5px 90px 0px #f0f0ff;
  border-radius: 18px;
  border-bottom: 5px solid #fff;
  height: 150px;
  font-size: small;
  overflow-y: hidden;
  cursor: pointer;

}
.icon-box:hover {    
  transform: translateY(-10px);
  transition: height 4s ease-in-out;
  border-color: #000080;
  height: max-content;
}

Answer №1

In order to achieve a smooth height change, the transition declaration should be placed in the .icon-box class rather than in .icon-box:hover

UPDATE 1

Adjust the height to 100% and utilize max-height for adjustment:

.icon-box {
  padding: 30px;
  background: #fff;
  box-shadow: 0px 5px 90px 0px #f0f0ff;
  border-radius: 18px;
  border-bottom: 5px solid #fff;
  height: 100%; /* included this */
  max-height: 150px; /* modified here */
  font-size: small;
  overflow-y: hidden;
  cursor: pointer;
  transition: max-height 4s; /* included this */
}

.icon-box:hover {    
  transform: translateY(-10px);
  border-color: #000080;
  max-height: max-content; /* edited and removed transition declaration */
}

UPDATE 2

Using values like max-content may not work as expected. It is recommended to use specific units (for instance: max-height: 100%;).

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

Is it possible for Express JS to receive incoming requests from external sources and then transmit the retrieved data to the front end of

I am currently developing a React JS frontend for my application, but I have an interesting idea to incorporate an external mobile app that can control certain elements on the screen, such as font styles. To achieve this functionality, I require the web ap ...

My preference is for only the content to have the ability to scroll

I have a code snippet that functions correctly in Chrome but not in IE or Firefox. I want to make only the content area scrollable when the viewport is less than 300px or if the content overflows. My main concern is with IE, specifically version 10 and abo ...

What is the solution to resolving the issue of props.match being

this is the code from my Editstudent.js file: async componentDidMount() { const stud_id = this.props.match; console.log(stud_id); } and here is a snippet from my App.js file: <Routes> <Route exact path="/" element={<St ...

How should one correctly align various classes in a cascading manner within CSS?

Here is an interesting challenge - I want each of these buttons to have their background image change when hovered over. However, I'm struggling with the class setup in my code. I've been trying to understand how to distinguish between divs and c ...

Unable to Change Navbar Color

Presented here is the code snippet for the navbar located in app/assets/views/elements: <nav class="navbar navbar-default" role="navigation"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> ...

How can I modify the color of a jQuery Mobile Select menu?

Is there a way to dynamically modify the color (background and text) of a single select menu in jQuery Mobile, without impacting other elements with the same class? I've experimented with various approaches, such as: $('#select').css({color ...

The CSS file that is defined first in the node.js HTML is the only one being utilized

Currently, I am incorporating CSS and JS files into my node.js/express application with the help of the ejs templating engine. Interestingly, while the JavaScript files are being successfully implemented, only the first included CSS file seems to be affect ...

How do I use jQuery to remove a dynamically added class from the page's header?

When using an inline editor to modify css classes, I encounter the need to remove and then re-add a class definition after making changes. Additionally, users have the option to delete elements, so it's important that the definition is also deleted. ...

What is the best way to center my navbar logo and have the navigation links encapsulate it on either side?

I am looking to achieve a design where my navbar brand is centered with the navigation links positioned on the left and right of it. When the screen size reaches md, I want the nav links to disappear into a burger menu while still keeping the nav brand vis ...

What are the steps to correct the misalignment of labels in my default Django form?

I recently set up a signup page and login page using django's default authentication features and forms. To enhance the design, I implemented crispy forms. However, I encountered an issue with the positioning of labels on the screen. You can view the ...

The Bootstrap drop-down feature refuses to open

I seem to be having trouble with a basic issue. I used the standard template from the bootstrap website, but for some reason, when I click on the dropdown menu in the navbar, it's not opening. Can someone help me figure out what's going wrong? & ...

CSS selector for targeting a parent element followed by a sibling element

Can someone help me with the following HTML and CSS issue? <form class="Form"> <FormField> <label class="FormLabel" ..> <div class="FormInput"> <div class="InputField"> <input../> </di ...

relocating the input field underneath the button

I need help figuring out how to arrange this. Here's an example link: http://jsfiddle.net/VBS4E/25/ Is there a way to position the input field directly below the button? Like this: ________ __________ __________ | Btn#1 | | Btn#2 | | Btn# ...

Bootstrap form toggle switch component for ReactJS

I'm having trouble figuring out why the default value for my react-bootstrap switch won't set to false (off). It seems like the only way it changes is when I trigger the onChange event handler. Am I overlooking something? Below is the section of ...

What method does nosotroshq.com use to achieve the navigation effect when hovering over a menu item?

Seeking advice from skilled individuals familiar with JQUERY: Can anyone explain the technique used by nosotroshq.com in their top navigation bar? Specifically, how do they create the slow animation when hovering over "ABOUT US"? Any insights would be ap ...

Error message in React/ Ruby on Rails: Encountered Uncaught TypeError when trying to access properties of undefined (specifically, 'id') while passing down a mapped prop

I have been grappling with this bug for the past few days and haven't found a solid solution yet. My objective is to route to an individual component, [http://localhost:4000/hris/employees/1], and display that specific 'employee' card on a ...

Using Javascript to generate a button that randomly chooses links within the webpage

Looking for help with JavaScript to select a link when a button is clicked on the page? Check out my code and let me know what I'm doing wrong. For the full code, visit: here HTML <!doctype html> <html lang="it" xmlns="http:/ ...

CSS not working with fixed positioning

As part of a school project, I am required to utilize the position fixed property to correctly position the cookie statement at the bottom right of the screen. However, when I attempt to move the element, it does not seem to display properly. ...

Adding a proptype for a setState method in React components

I am currently developing a reusable component for a project. This particular component includes user and setUser as props, much like the example provided below. const UserComponent = ({ user, setUser }) => { const calcHandler = useCallback(() =& ...

Error: The function channel.on cannot be recognized within the Twilio API

I am encountering an issue with a function in my ReactJS application that is responsible for initializing the Twilio services I am utilizing. It appears that the Twilio channels are not being accessed properly. Below is the snippet of code causing the prob ...