CSS Transition not activating upon initial mouseover

My attempt at a simple transition is not working properly on Safari. I am trying to change background images from A to B on hover, but the transition is not smooth when I first hover over the element. Instead of gradually fading in/out, it instantly changes.

You can view my code on JSFiddle here - https://jsfiddle.net/RalphCSD/z9nx30co/4/

I am using a Wordpress site and wondering if that could be causing any issues.

Below is the HTML & CSS I have included. If anyone spots any errors that might be causing the problem, I would greatly appreciate your help.

.colBox {
  width: 100%;
  max-width: 300px;
  min-height: 400px;
  background-image: url("http://www.scatterboxshop.ie/wp-content/uploads/2019/11/Scatterbox-Shop-CTA-Cushions.jpg");
  right: 0px;
  transition: all .5s ease-in-out;
  -webkit-transition: all .5s ease-in-out;
  -webkit-backface-visibility: hidden;
}

.colCon {
  padding-top: 50px;
  padding-left: 35px;
  max-width: 200px;
  color: white !important;
  font-family: 'Montserrat', sans-serif;
}

.colHead {
  color: white !important;
  font-weight: 400 !important;
  font-size: 12px !important;
}

.colHeadLg {
  font-size: 40px;
  font-weight: 700;
  padding-top: 50px;
}

.colP {
  font-size: 12px;
  line-height: 16px;
}

.moreArrow {
  font-size: 20px;
}

.colBox:hover {
  width: 100%;
  max-width: 300px;
  min-height: 400px;
  background-image: url("http://www.scatterboxshop.ie/wp-content/uploads/2019/11/Scatterbox-Shop-CTA-Cushions-BG.jpg");
  -webkit-backface-visibility: hidden;
}

.hover-div {
  width: 200px;
  margin-top: 70px;
}

.hover-div .stuff {
  margin-top: 0;
  position: relative;
  width: 100%;
  z-index: 2;
  -webkit-transition: margin-top 0.5s;
  transition: margin-top 0.5s;
}

.hover-div .stuff-hidden {
  height: 0;
  width: 100%;
  overflow: hidden;
  -webkit-transition: height 0.5s;
  transition: height 0.5s;
}

.hover-div:hover .stuff {
  margin-top: -40px;
}

.hover-div:hover .stuff-hidden {
  height: 40px;
}
<div class="colBox">
  <a href="#">
    <div class="colCon">
      <h2 class="colHead">CUSHION COLLECTION</h2>
      <div class="hover-div">
        <div class="stuff">
          <p class="colHeadLg">Cushions</p>
          <p class="colP">Our luxury feather filled cushions are statement pieces each with a story to tell</p>
        </div>
        <div class="stuff-hidden">
          <p class="moreArrow">More <span><i class="fas fa-arrow-right"></i></span></p>
        </div>
      </div>
    </div>
  </a>
</div>

Answer №1

Consider adjusting the transition time to 1.5 seconds instead of 0.5 seconds:

.colBox {
  width: 100%;
  max-width: 300px;
  min-height: 400px;
  background-image: url("http://www.scatterboxshop.ie/wp-content/uploads/2019/11/Scatterbox-Shop-CTA-Cushions.jpg");
  right: 0px;
  transition: all 1.5s ease-in-out;
  -webkit-transition: all 1.5s ease-in-out;
  -webkit-backface-visibility: hidden;
}

Answer №2

The jumping effect occurs in all browsers, it's just that the rest of them store the hover image in their cache. The solution is to preload the image before the hover event takes place. You can achieve this by setting the image as the background for the parent element.

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

Remove dynamically created elements from an AngularJS div

Is there a way to remove an item from the criteria list when clicking the delete button? Currently, only the filter is being refreshed and not the tables. Any suggestions on how to resolve this issue? HTML <ul class="list-unstyled"> <l ...

Ways to Retrieve the Text From the Selected Index in Datalist Element

I need to extract the inner text of the option tag using pure JavaScript This is the HTML code I am working with: <input list="in" name="i_n" class="form-control" placeholder="Enter Item Name" required> <datalist id="in" onChange="rate(this)"&g ...

Unable to expand the dropdown button collection due to the btn-group being open

Having trouble with the .open not working in Bootstrap 4.3 after adding the btn-group class to open the dropdown... I am looking for a way to load the dropdown without using JavaScript from Bootstrap. This is the directive I am trying to use: @Host ...

Determining the Last Modified Date for a Sitemap using Javascript

I am trying to replicate the date format shown within <lastmod></lastmod> tags in a sitemap.xml file. How can I do this? The desired output is as follows: <lastmod>2016-01-21EEST18:01:18+03:00</lastmod> It appears that 'EEST ...

How can I create a unique visual effect on the background in frontend development using chipped design techniques?

Creating a static website utilizing React. Description I am looking to incorporate a visual effect into the website pages, similar to the one demonstrated below. visual effect The goal is to design a rectangular background with triangles cut out from it ...

What steps should I take to transition from a table-based layout to a more semantic HTML structure with a CSS-based layout?

Looking at the image presented, a significant portion of the HTML code has been structured semantically, with CSS being utilized for overall aesthetics. However, despite concerted efforts, resorting to a table was necessary to ensure that the segment on th ...

Tips for triggering window load event on a particular page

I need to trigger the windows.load event on a specific page. Currently, I have set it up like this: $(window).load(function(){ if(document.URL == "/car-driving.html") { overlay.show(); overlay.appendTo(document.body); $('.popup' ...

Creating a div that becomes fixed at the top of the page after scrolling down a certain distance is a great way to improve user experience on a

I am struggling to create a fixed navigation bar that sticks to the top of the page after scrolling 500px, but without using position: fixed. Despite trying various solutions, none seem to work due to the unique layout of my navigation bar. Strangely enoug ...

Retrieve the file name of the webpage from the URL bar

Is there a way to retrieve the page name from the address bar using jquery or javascript instead of PHP? I am working on an HTML website and would prefer not to use PHP for this specific task. For example, if the address is www.mywebsite.com/hello.htm, ho ...

swapping out an external CSS file in React for a new CSS file

My React app is quite large and includes four main CSS files (darkLTR, lightLTR, darkRTL, lightRTL), which may not be the most efficient setup. The templates were provided by my boss, and I was instructed to use them instead of Material UI, which I initial ...

Guide to centering the navigation bar within a container using Bootstrap 4

I'm looking to center the navbar on my webpage. How can I style it so that it appears in the middle of the page? Currently, it's aligned with the left side of the page. section class="navbarSection"> <div class="contain ...

How can I position 7 images absolutely within a specific div?

I've been working on a website where users can have their avatars displayed using a JS function that loads 7 different images onto the page. These images correspond to different elements such as skin base, hair, eyes, mouth, shirt, shoes, and pants, a ...

Scrollable container with jQuery draggable functionality

I am currently working on implementing a draggable list that I want to contain within a scrollable div. $( ".draggable" ).draggable(); Here is the fiddle I have created for this: http://jsfiddle.net/YvJhE/660/ However, the issue I am facing is that the ...

Series of responses cascading from one another

Users are experiencing an issue where the need for adjusting margins based on the depth of responses in posts. Currently, this involves setting a margin-left value of 40px for one level deep reactions and 80px for two levels deep, and so on. To address th ...

What is the best way to create a flexible Ul-LI menu?

Is it possible to create a flexible menu where clicking on an item does not cover other items in the menu? #demo { margin: 30px 0 50px 0; font-family: sans-serif; } #demo .wrapper { display: inline-block; width: 180px; height: 20px; position ...

How can I retrieve XML through a URL using HTML5 and JavaScript?

Currently, I am looking to access an XML file through a URL link. My main goal is to retrieve the file automatically and extract its contents for further processing. However, I am facing difficulties in finding the appropriate method to obtain and read t ...

Unable to display a horizontal scroll bar

I'm having some trouble with implementing a horizontal scroll feature and can't seem to make it work. If you want to take a look, here is the fiddle Please provide me with assistance in identifying what mistakes I may be making edit Here is th ...

Tips on using htmlspecialchars in combination with a href:To safely include links in

If I have the following code: $text = "please visit this <a href='http://example.com'>site</a>." $text = htmlspecialchars($text); echo $text; The output will be please visit this <a href='http://example.com'>site< ...

Is there any way to remove the two default aspNetHidden Divs in asp.net web forms?

After creating an empty webform page in asp.net, the generated code looks like this: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Threetier.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org ...

Learn how to activate a JS native event listener using jQuery for the 'change' event

This question is unique from the one found at How to trigger jQuery change event in code. The focus here is on the interaction of jQuery with native event listeners, rather than jQuery event listeners. I am using addEventListener to bind a change event fo ...