Change when the mouse departs

I am currently working on implementing a transition effect.

My block consists of 3 main parts:

  1. Base block
  2. Hover image (coming from the top)
  3. Hover title (coming from the bottom)

When hovering the mouse, there is also a background-color transition that occurs.

Everything functions correctly when the cursor hovers over, and the objective is to create a similar reverse animation when the cursor moves away.

#studio {
  margin-top:50px;
  margin-left:50x;
}

#studio #portfolie {
  position: relative;
  z-index: 10;
}
#studio #portfolie .content-porfolio {
  text-align: center;
  width: 800px;
  margin: 0 auto 140px;
}
#studio #portfolie .project-title--hover {
  bottom: -19px;
  transition: bottom .7s ease;
}
#studio #portfolie .project-logo--hover {
  margin-top: -100px;
  transition: margin-top 0.7s ease;
}
#studio #portfolie .md-trigger:hover .project-title--hover {
  display: block !important;
  bottom: 25px;
}
#studio #portfolie .md-trigger:hover .project-logo--hover {
  display: block !important;
  width: 70%;
  margin-left: 15%;
  height: 100px;
  background-repeat: no-repeat;
  margin-top: calc((25%-attr(height))/2);
  background-size: contain;
  background-position: center;
  position: absolute;
  overflow: hidden;
}
#studio #portfolie .project-logo--base {
  height: 100%;
  width: 100%;
  background-repeat: repeat;
  position: absolute;
  overflow: hidden;
}
#studio #portfolie .hover-container {
  transition: background-color 0.5s ease;
  background-color: transparent;
}
#studio #portfolie .md-trigger:hover .hover-container {
  background-color: #F1CE34;
  height: 100%;
  width: 100%;
  position: absolute;
}
#studio #portfolie .content-play {
  margin-bottom: 15px;
  position: relative;
  z-index: 2;
}
#studio #portfolie .content-play .slide {
  display: none;
}
#studio #portfolie .content-play > * {
  width: calc(100% * 1 / 3 - 40px);
}
#studio #portfolie .content-play .play {
  height: 200px;
  cursor: pointer;
  position: relative;
  color: #FFF;
  text-transform: uppercase;
  margin-bottom: 40px;
}
#studio #portfolie .content-play .play span {
  font-size: 0.8em;
  position: absolute;
  font-family: 'ProximaNovaA-Black';
  left: 50%;
  -webkit-transform: translateX(-50%);
  -moz-transform: translateX(-50%);
  -ms-transform: translateX(-50%);
  -o-transform: translateX(-50%);
  transform: translateX(-50%);
  display: block;
  width: 100%;
}
<section id="studio">
<div id="portfolie">
<ul class="content-play clearfix grid-3">
  <li data-modal="modal-video-1" class="first play md-trigger slide" id="first-play" style="display: list-item;">
    <div class="project-logo--base" style="background-image: url(http://storage.tvanouvelles.ca/v1/dynamic_resize/sws_path/tvanouvelles_prod/bc7caa6d-8748-495c-8522-a7fc17513ce7_ORIGINAL.jpg?quality=80&size=800x&version=0)">
      <div class="hover-container">
        <div class="project-logo--hover" style="background-image: url(http://www.esoterisme-exp.com/File_images/2012/1205/Carre-bleu.png)"></div>
        <span class="project-title--hover">Tennis festival</span>
      </div>
    </div>
  </li>
</ul>
</div>
</section>

Answer №1

You can utilize the :not(:hover) pseudo-class.

If you're encountering an issue where the blue square is not returning to its original position, consider implementing the following adjustments:

#studio #portfolie .project-logo--hover {
  top: -100px;
  transition: top .7s ease;
  width: 70%;
  margin-left: 15%;
  height: 100px;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  position: absolute;
}
#studio #portfolie .md-trigger:hover .project-title--hover {
  display: block !important;
  bottom: 25px;
}
#studio #portfolie .md-trigger:hover .project-logo--hover {
  display: block !important;
  top: calc((25%-attr(height))/2);
}
#studio #portfolie .hover-container {
  transition: background 0.7s linear;
  background-color: #FDF200;
  height: 100%;
  width: 100%;
  position: absolute;
}
#studio #portfolie .md-trigger:hover .hover-container {
  background-color: #F1CE34;
}

Answer №2

Check out the "Rise to Shine" background effect transition here and here. I believe it might be a good fit for what you're looking for.

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

Animating two elements on scroll at specific point with speed problem

Trying to create an animation with two different images once a user reaches a specific point on the page. The animation works, but there is an issue when using a trackpad - the movement appears slow compared to scrolling with a mouse. I've already att ...

What is the best way to calculate the total sum of the first element in each index of an array when using ng

I am looking to calculate the sum of the first elements from all indexes of an array using ng-repeat in AngularJS. My goal is to declare a variable and increment its value with each iteration of ng-repeat, then display that variable at the end. Below is ...

What is the best way to format MarkDown content within a nextJs environment?

Markdown-it is successfully converting markdown to html in my Nextjs project. However, I am facing a styling issue with specific elements such as h2, h3, ul, and li. Here's the code snippet: <h1 className="text-3xl mb-3 leading-snug d ...

Turn off the text cursor when inside a specific div block

Check out these two fiddles: fiddle 1 and fiddle 2 The only variation between the two is a single CSS property in .category -webkit-user-select: none; In fiddle 2, when you click and drag an element, the cursor remains as a pointer instead of changing t ...

Firefox Flaw: Animation Issues with CSS

My Website has a CSS animation that creates a hover effect on a button. While the animation looks good in Chrome and IE, I encountered an issue with Firefox. https://i.sstatic.net/y2po7.png Some white pieces are still visible after hovering. Here is th ...

Is there a way to implement a confirmation form within the properties_list view to ensure the user intends to delete the property

Is there a way to modify the code below so that instead of directly deleting the property, a confirmation form (such as a modal) is displayed for the user to decide whether to proceed with the deletion or not? views.py def property_list(request): proper ...

Exploring Web Scraping Through Dual System Security

I come seeking guidance on how to navigate a website with two different security systems in place. The first system requires a username and password, which I have successfully managed to handle. However, the second security system only requires a password ...

Adjust the JavaScript variable upon pressing the "c" key

I'm trying to figure out how I can toggle the value of variable x in JavaScript when the key "c" is pressed. Specifically, I want x to change from 0 to 1 when "c" is pressed and revert back to 0 when it's released. I have already defined and name ...

Developing an IF statement in JavaScript that relies on hexadecimal color values

I've created a JavaScript code that changes the background color of my webpage every time it loads: document.getElementById("band").style.background = '#'+(Math.random()*0xFFFFFF<<0).toString(16); To improve visibility, I am aiming t ...

Ways to ensure the image stays fixed even as the screen dimensions fluctuate. HTML/CSS

Struggling to create an HTML header with a title and image positioned on the right side, but facing issues with the image shifting over the title when screen size changes. How can I ensure the image stays in place? Have tried various solutions without succ ...

Increase the gap between columns in Bootstrap for a better layout

I have implemented a web layout using bootstrap 3. You can view the JSFiddle here. In order to make the layout responsive, I had to structure it in a slightly unconventional way. The final output on small screens includes three information boxes within an ...

A guide to adjusting the size of a mat-button using an svg mat-icon

I have PrimeNg and Angular Materials buttons on the same td. I am attempting to resize my mat-buttons to match the size of my pButtons but they are not adjusting properly. Should I consider using a different type of button with my icon? HTML <button ma ...

What is the proper way to incorporate a hashtag (#) into a PHP parameter within a URL

Currently, I am sending a PHP request to a login handler using the following URL: https://example.com/test.php?username=test123&password=hiuhsda3#24 However, I need to retain the hashtag in either the password or username along with anything that come ...

Media queries for the header background image display

I am currently working on a small web project and I want to change the background image in the header section while also making it responsive. I attempted to use a class called "header_accueil" in my header to distinguish different sections of the site, bu ...

Side-to-Side Bootstrap Display Panel

I have been attempting to customize a Bootstrap panel to create a horizontal version, but I am struggling to align the panel heading vertically with the content in the panel body. I believe it may be related to clearing the divs. Front-end development is ...

The Div element containing the rollover button/picture is failing to resize properly as the window is decreased in size

Whenever I try to resize my browser window in Firefox or Chrome, the div ends up moving instead of resizing. I've searched on stackoverflow for answers but haven't found any solutions yet. Can someone please help me with this issue? Here is what ...

The `d-flex flex-column` is causing the image within the div to be hidden

The setup looks like this: <div className="d-flex flex-column"> <div> Text </div> <div style={{ backgroundImage: 'url(...)' }}> </div> </div> The URL is functioning correctly. The div element is ...

What is the best way to arrange the elements vertically within a flex container?

In my current code snippet, I have the following setup: <section class="body1"> <h1 class="text1">Tours around the world</h1> <h3 class="text1">Great experiences</h3> <form action="/respuestaUsuario/"> ...

Acquire a structured list of the focus order within the DOM elements

It intrigues me how the DOM is constantly changing. I'm curious if there's an easy way to retrieve a sorted list of focusable elements within the DOM at any moment. This would encompass nodes with a specified tabindex value that isn't -1, as ...

Discover the character "’" as well as other fascinating symbols

When transferring content into an HTML file from sources like Word documents or PDFs, I want to ensure that the special quotes and apostrophes are converted to their standard counterparts. In simpler terms, I desire to switch characters like ’ with &apo ...