Experience the smooth glide on a CSS image

I am looking to add a unique animation to my menu, specifically a slide-down color effect instead of the typical fade transition on the first two divs. I envision it as a curtain-like animation.

When hovering over an image, I want a colored panel to smoothly slide down and overlay it. Below is a snippet of my menu:

@import url(http://fonts.googleapis.com/css?family=Lato:400,900);  /* <-- Just for the demo, Yes I like pretty fonts... */

.square {
    float:left;
    position: relative;
    width: 30%;
    padding-bottom : 30%; /* = width for a 1:1 aspect ratio */
    margin: 0;//1.66%;
    background-position:center center;
    background-repeat:no-repeat;
    background-size:cover; /* you change this to "contain" if you don't want the images to be cropped */
}

.img_1-1{background-image:url('https://farm4.staticflickr.com/3766/12953056854_b8cdf14f21.jpg');}
.img_1-2{background-image:url('https://farm7.staticflickr.com/6092/6227418584_d5883b0948.jpg');}
.img_1-3{background-image:url('https://farm8.staticflickr.com/7187/6895047173_d4b1a0d798.jpg');}

.img_2-1{background-image:url('https://farm8.staticflickr.com/7163/6822904141_50277565c3.jpg');}
.img_2-2{background-image:url('https://farm7.staticflickr.com/6139/5986939269_10721b8017.jpg');}
.img_2-3{background-image:url('https://farm4.staticflickr.com/3165/5733278274_2626612c70.jpg');}

.img_3-1{background-image:url('https://farm9.staticflickr.com/8429/7862595906_8f953fd25b.jpg');}
.img_3-2{background-image:url('https://farm7.staticflickr.com/6083/6055581292_d94c2d90e3.jpg');}
.img_3-3{background-image:url('https://farm4.staticflickr.com/3771/13199704015_72aa535bd7.jpg');}

// remaining CSS code here...

This is the animation effect that I wish to achieve when hovering over the images: http://jsfiddle.net/gregmatys/4x9Tf/light/
Thank you for your assistance.

Answer №1

In order to achieve the desired layout, it is important to place the image element within the #wrap div and before the #slide div. Additionally, the #wrap div should be given a CSS property of position:relative. This step is crucial as it allows for the absolute positioning of the #slider div with values of top:0 and left:0, ensuring that it appears above the image and covers it seamlessly.

You can refer to this JS Fiddle example and implement the following code within the #wrap and #slider:

CSS:

#wrap {
  position: relative;
}
#slider {
  position: absolute;
  top: 0;
  left: 0;
}

Revise your div#wrap structure to match the suggested format below:

<div id="wrap">
  <img src="//placehold.it/200x200?text=IMG">
  <div id="slider">
    <p>Input your content here...</p>
  </div>
</div>

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

Modifying the default accordion svg icon in Bootstrap 5: A comprehensive guide

Looking to customize the bootstrap icon for accordions Instead of the standard arrow icon, I want to utilize the <i class="bi bi-plus-circle"></i> and <i class="bi bi-dash-circle"></i> bootstrap icons. One icon ...

Looking for assistance in streamlining the code

On my Drupal page, I have multiple divs and a JavaScript function that checks for content inside each one: if ($('.accred').length) { $('#accred').show(); } else{ $('#accred').hide(); } // More code follows... T ...

yet another problem with overflow-x being hidden while overflow-y is visible

I am currently working on creating a tab overflow user interface that is similar to what Firefox uses. This involves utilizing a combination of fixed width containers and a fluid width container in the middle to hold the tabs. The challenge arises when th ...

The active tabs or placeholders do not update properly when I click on them

Is there anyone who can help figure out why the tabs are not functioning as expected? The goal is for the tabs to change the input field placeholder and perform a search based on the active tab. If you're able to assist, please review my complete cod ...

Show the latest outcome across several tables in Django

I am currently working on a Django project where I need to display the most recent result from multiple tables. This means that my page will contain several Divs, each showing the value and time of the latest entry in a specific table. Below is some initi ...

`Place text to the right side of the image`

Is there a way to align all three lines of text to the right of an image without wrapping on the second line? If you have any suggestions, please let me know! Check out this JSFiddle for reference. CSS: img { min-width:75px; height:90px; ve ...

What is the best way to customize the background color of a highlighted ToggleButton in react-bootstrap?

Currently, I'm using react-bootstrap and facing a challenge in changing the background color of a chosen <ToggleButton> to blue. For instance: <ButtonToolbar> <ToggleButtonGroup type="radio" name="options" ...

Space between pixels at the bottom of a division

There's a puzzling issue here with a simple fix waiting to be uncovered. In the example below, a pixel gap has formed between the bottom of two images and the DIV elements (home-top or home-bottom). How can this bothersome space be eliminated? .con ...

When the CSS style sheet is not embedded within the HTML document, it fails

I'm facing an issue while trying to apply currency formatting to an HTML table in order to have it display correctly when opened in Excel. Initially, I tried doing this inline and it worked fine, like so: <td style="mso-number-format:$\##&bso ...

"Enhance user experience with autofocusing on form fields within an overlay

Despite spending hours searching, I can't seem to figure out a seemingly simple task. I am trying to set autofocus on a form field within an overlay that opens when a button is clicked. The overlay is implemented using basic jQuery overlay code. $(f ...

Missing Image: Bootstrap NavBar Display Issue

Having trouble inserting an image into my Bootstrap navbar, only the alt text is showing up. Does anyone have a solution for this? Bootstrap Version: CDN Version 5.0 Beta Screenshots: https://i.sstatic.net/vBNYp.png https://i.sstatic.net/v8lwu.png https: ...

Interacting with the column tags within HTML tables through the .NET WebControls Table in a programmatic way

As per the information provided on this website: The HTML5 table contains col tags... <table width="100%"> <col style="width:40%"> <col style="width:30%"> <col style="width:30%"> <tbody> ...

Unable to execute main JS template in Angular partial view, JQuery function also fails to work on the partial view

As a newcomer to angular, I am facing a challenge with the JS file that I have initiated on the index.html page. While working with angular, I have had to create partial views of different pages. The functions in this file handle tasks such as minimizing a ...

Adjusting the panel dimensions based on the screen size

One feature on my website is a sliding panel (Image 1) located on the right side. It appears and disappears when a button is clicked, covering the entire height of the screen.https://i.sstatic.net/dF5Zc.jpg Here's the CSS code for this sliding panel- ...

What steps do I need to follow to create a 3D shooting game using HTML5 Canvas?

I'm eager to create a 3D shooter game with HTML5 Canvas, focusing solely on shooting mechanics without any movement. Can anyone provide guidance on how to accomplish this? I've looked for tutorials online, but haven't come across any that m ...

Converting Variable Values to Element IDs in JavaScript: A Helpful Guide

Is it possible to declare a value in variable A and then access that value as an id in variable B using the method getElementById()? var A = 10; var B = document.getElementById(A); console.log(B); ...

What is the best way to apply box shadow to a particular region using CSS?

I am looking to add a box shadow using CSS, but I only want it in a certain area of the box. https://i.sstatic.net/dcFZu.png In the screenshot above, you can see that I have a blue header on my website. I would like to add a shadow to this header, specifi ...

Child div height exceeds parent container bounds

Take a look at this example here: http://fiddle.jshell.net/dwuZp/15/ Can you determine why the "icons" div is overflowing the height of its parent div, "logoTimeAndIcons"? To visualize the issue, try changing the height to 50%. Your assistance is great ...

Is receiving an error message about a "stray start tag footer" in your HTML validator?

I am perplexed by the error message I am receiving: Stray start tag footer. All I have included here is the tags: <!doctype html> <head> <title>title</title> <meta charset="UTF-8"> <meta name="keywords" cont ...

Limiting the options available in dropdown menus

In my HTML code, I have two drop-down lists that look like this: <select name="from" id="abs-from-1"> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> ...