CSS3 Transition does not activate when hovering over it

My index page features various links to reports, each styled as a div with an image, text, and rounded corners. Currently, the background color of the div changes on hover, but I wanted to add a Transition effect to make them stand out more. The higher-ups enjoy those kinds of enhancements. However, I'm facing some challenges in implementing this.

.card {
  float: left;
  width: 32%;
  padding: 5px;
  margin: .5%;
  text-align: right;
  border-radius: 15px 50px;
}

.card:hover {
  -webkit-transition: width 2s, height 4s;
  /* Safari */
  transition: width 2s, height 2s;
  background-color: #b9d6a0;
  color: black;
}

.card>img {
  margin-bottom: 12px;
}

.card-text {
  font-size: 85%;
}

.dashboardlink {
  width: 100%;
  height: auto;
  border-radius: 15px 50px;
}
<div class="container">
  <div class="row">
    <div class="card">
      <a href="/ip" target="_blank">
        <img class="dashboardlink" src="/images/ip.png" alt="Immediate Pays">
      </a>
      <p class="card-text">Immediate Payments</p>
    </div>

    ... (other card divs) ...

  </div>
</div>

I am relatively new to CSS animations and currently refining a bootstrap template used for this page. Any suggestions on how to enhance or optimize my approach would be greatly appreciated.

Here's a snapshot of the current look of the links on the page: https://i.sstatic.net/yeJtH.png

Although the links lead to ShinyDashboard Apps, this particular page is built using just HTML.

Answer №1

To enhance the visual appeal, consider making some adjustments to the transition property placement in the .card class. Initially, set the transition property with the original size specifications. Subsequently, exclude the transition property from .card:hover and incorporate the updated size parameters there. For additional guidance, refer to this resource: https://www.w3schools.com/css/css3_transitions.asp

.card {
  float: left;
  width: 32%;
  padding: 5px;
  margin: .5%;
  text-align: right;
  border-radius: 15px 50px;
  -webkit-transition: width 2s, height 4s;
  /* Safari */
  transition: width 2s, height 2s;
}

.card:hover {
  width: (insert new size as needed)
  background-color: #b9d6a0;
  color: black;
}

Answer №2

It seems like you're looking for a simple way to achieve a smooth transition effect for background changes.

Check out this example

transition: width 2s, height 2s;

However, the rule you've provided doesn't seem to be correct. The transition property is used to smoothly animate an element's properties. If you intend to animate the width or height, you should specify the starting and ending values for a smooth transition effect.

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

Instructions for setting a cookie to conceal a notification bar upon the second page load

I am looking for the following scenario: When a new visitor lands on my website, a notice bar fixed to the bottom of the screen becomes visible. After clicking on a menu item to navigate to another page, a cookie is set upon the second page load. This co ...

increasing the margin around a heading inside a container with existing padding

I'm currently struggling to apply padding to the header of this container. For some reason, I can't seem to add any padding to the left or right. The image below illustrates the current appearance. Here's the code snippet: <?php $feed = ...

Add a click event listener to the body element using a button click, without causing it to trigger

What is the current situation: A button is clicked by the user The menu opens (list items display = block) The function to close the menu is connected to the <body> The function to close the menu is immediately triggered, causing the menu to close ...

What is the best way to incorporate an animation into my text bubble? Specifically for a Twitch Alert, such as a bits alert

I'm attempting to customize my Twitch Alert in Streamlabs using code. Is there a way to incorporate animation into the text balloon? I've looked for tutorials or guides but haven't had any luck, so I could use some guidance. CSS #alert-use ...

Automatic keyboard suggestions not working for HTML search input using Ajax

I am currently working on a PHP web application that uses a MySql database. I have implemented a search suggestion box using ajax. The issue I am facing is that the suggestions can be selected with the mouse and auto-completed, but not when using the keybo ...

Floating hover box gracefully descends as you hover over it

While working on this particular site, I encountered an issue with the password being set as joint123. There was a map displayed with icons on the right side, and when hovering over the icons, the corresponding address would appear. However, the problem ar ...

The word-break CSS property is ineffective in this situation

I've been experimenting with the word-break css property, but I just can't seem to get it to work even when using a simple example. Here's my code: React: render() { return ( <h5 className="word-break">A very very long line.... ...

"Learn how to properly load the style.css file from the root directory into your WordPress page.php and single.php files

Having an issue with my WordPress theme. The style.css stylesheet does not seem to be loading in the page.php contents. I noticed that when I add <div class=w3-red"> <button class="w3-btn w3-red"> and other related codes while editing a post in ...

The margin-left and margin-right in HTML CSS are not cooperating to center a div

I'm currently diving into the world of CSS and HTML, but I've hit a roadblock. The margin-left and margin-right in the ".logo" div class are refusing to center the div as expected. Despite conducting research and meticulously checking over the co ...

React: The HTML Details element toggles erratically when initially set to open

I am exploring the use of the HTML <details> tag to create an expandable section with semantic HTML in conjunction with React. The default behavior of <details><summary></summary></details> works well, and for the small perce ...

Difficulty viewing image in Firefox using HTML <img> tag

I'm encountering an issue with rendering an img tag in an HTML page. The img source is a file located on a remote server. Surprisingly, when attempting to display the image in Firefox using: file://///server/folder1/folder2/name.jpg it shows up prop ...

Make sure the top edge of your Bootstrap 4 dropdown menu is perfectly aligned with the bottom edge of your

Trying to make a Bootstrap 4 navbar dropdown display right below the navigation bar, but it consistently shows slightly above the bottom edge of the navbar. Is there a way to make this happen without fixing the height of the navbar and using margin-top fo ...

Spacing at the bottom of a table border

Currently, I have a table where I am utilizing CSS to display a bottom border. .inset { border-bottom: 1px solid #dadce0; } I am aiming to have some padding on the left and right sides similar to using a <hr align="center" width="80%">, but I ...

Just dipping my toes into Django/Python and feeling completely bewildered by why my webpages won't connect

I'm having trouble with my webpage links. It seems like the file paths are incorrect. I've attempted to link three pages: The homepage The 'artists' icon on the top right of the homepage, linking to 'registerprofessional.html&apo ...

A stylish Bootstrap list group featuring large Font Awesome icons

I am working with a Bootstrap 5 List Group element on my webpage. To enhance its visual appeal, I want to include oversized Font Awesome icons. After some styling and using a span tag, I managed to add the icon successfully. However, the issue I am facing ...

In this scenario, why is the `position: fixed` property anchored to the document rather than the viewport?

I have a gallery set up with a custom lightbox feature that I designed. The lightbox is styled with position:fixed and top:0, so theoretically it should stay in the same position regardless of scrolling. However, I am experiencing issues where this is not ...

The Google Map is not showing all the details

Our app is developed using ReactJS on Rails API, with a Google map integrated. However, when visiting this link and clicking "Map View", some grey space appears under the Google Map. An example image can be found here: example We are having trouble findi ...

Ensure that the Bootstrap image element maintains its full height without resizing

While working on my Angular application, I encountered an issue with designing a side list-group of recent blogs using Bootstrap 4. When the aspect ratio is changed to mobile view, the images resize and become smaller to fit into the div as the title lengt ...

Tips for aligning a form in the center of a webpage

I have a code snippet using material-ui that I want to center on the page, but it's not working. Can someone please help me fix this issue? Thank you in advance. import React from 'react'; import { makeStyles } from '@material-ui/core ...

How to insert additional spacing within an input tag class in dynamic HTML using jQuery

When creating an html table dynamically from json data, I encountered an issue with adding space inside my input button control. It seems that after separating two classes with a space, the code is not functioning properly in this snippet environment. Howe ...