Creating a seamless blend of a masked image as a thumbnail and full-sized picture can be quite challenging

I'm attempting to achieve an effect similar to the one showcased here:

When you hover over an image in that particular section, the image enlarges smoothly to cover most of the screen. What's noteworthy about this transition is that the larger version of the image precisely aligns with the thumbnail image, giving the impression that the image is uncovering itself rather than just expanding.

Despite multiple attempts, I've been unable to find a solution. My current efforts are far from the desired outcome.

EDIT:

The script below is my best attempt so far but still falls short of the intended solution:

This script triggers the display of a DIV containing the image as a background upon hovering over it. The issue is that it seems like the image is expanding instead of "uncovering".

$(document).ready(function(){
    $('.ejemplo').hover(function(){
        console.log('hoveeeeer');
        var img = $(this).data('img');
        console.log(img);
        $('.c1').css(
            'background-image', 'url('+img+')',
        )
        $('.c1').show()
        $('.c1').css(
            'opacity', '1'
        )
        $('.ejemplo').css(
            'opacity', '0'
        )
        $('.header_highlights').css(
            'opacity', '0'
        )

        var audio1 = $(this).data('audio');
        var stereo = document.getElementById(audio1);
      //Example of an HTML Audio/Video Method
        stereo.play();
    }).mouseout(function(){
    console.log('no hover')
    $('.c1').hide()
    $('.c1').css(
        'opacity', '0'
    )
    $('.ejemplo').css(
        'opacity', '1'
    )
    $('.header_highlights').css(
        'opacity', '1'
    )
    var audio1 = $(this).data('audio');
    var stereo = document.getElementById(audio1);
    stereo.pause();
    });
  });

HTML:

  <div class="container-flex w-container" style="">
        <?php $behind_the_image_images = get_field( 'behind_the_image' ); $count= 0;?>
        <?php if ( have_rows( 'behind_the_image' ) ) : ?>
    <?php while ( have_rows( 'behind_the_image' ) ) : the_row(); ?>
           <div data-w-id="50eadee3-1406-6c5c-563f-0957896a13d2" style="opacity:0" class="div-block-5">

   <a id="hover-<?=$count?>" href="#"  class="link-block-4 _1 link-<?=$count?> w-inline-block ejemplo" style="position:relative;" data-audio="audio-<?=$count?>" data-img="<?= get_sub_field('image'); ?>"></a>

            <div class="header_highlights _2"><?= get_sub_field( 'title_image' ) ?></div>
            <style>.link-<?=$count?> {background-image:url('<?= get_sub_field( 'image' ); ?>')!important;}</style>
                    <audio id="audio-<?=$count?>">
              <source src="<?= get_sub_field('audio_hover'); ?>" type="audio/mpeg"></source>
              <source src="nav.ogg" type="audio/ogg"></source>
            </audio>
          </div>
          <?php $count++; ?>
            <?php endwhile; ?>
        <?php endif; ?>
        </div>
      </div>
      <div style="" class="c1"></div>
      </div>

Answer №1

My solution involved using clip-path and jQuery to achieve the desired effect.

JS:

jQuery(document).ready(function(){
  jQuery(".bimg").hover(function(){
    jQuery(".bimg").attr("style","clip-path: inset(0 0 0 0);");
    }, function(){
    jQuery(".bimg").attr("style","clip-path: inset(30% 60% 35% 12%);");
  });
});

CSS:

.bimg {
max-width:none;
position:absolute;
left:-60%;
padding:0px;
margin: 0%;
top:-650%;
}

HTML

<img src="<?= get_sub_field('image'); ?>"  width="1000px;" style="-webkit-clip-path: inset(30% 60% 35% 12%);clip-path: inset(30% 60% 35% 12%);" height="650px;" class="bimg">

The image may need additional CSS adjustments for perfect display, as well as ensuring cross-browser compatibility and responsiveness, but the fundamental concept is demonstrated here.

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

Textures in ThreeJS that are of type transparent PNG and have

Having trouble understanding an issue I encountered with ThreeJS. There's a basic cube on a page and I've got a PNG image of a white question mark, with the rest of the image transparent. When I apply the texture to the cube; cubeGeometry = new ...

The application of textures is not being done correctly

Trying to incorporate two textures - one for the wall and another for the floor. However, after rendering, only a solid color is displayed instead of the desired texture. Below is the configuration of my scene and camera: const tempScene = new THREE.Sc ...

"Exploring the Effects of Opacity Gradation in

Is there a way to create a face with an opacity gradient in three.js since rgba is not supported and the alpha is not used? I've heard it might be achievable with a ShaderMaterial and custom attributes, but being new to WebGL, I'm still trying t ...

Iterate through the list that is retrieved using JSON

Hello there, I'm fairly new to MVC and I've encountered a problem that I hope someone can help me with. I am sending a list like the one below to my view using "return JSON();" public static List<SelectListItem> Foodlist = ...

How to efficiently handle conditional rendering in React when passing data from Children to Parent

Just starting out with React, currently exploring react 16.13 and looking into how to achieve the following: Sending data from Child Components to Parent Components If the passed data is "true", display the specific Child component on the Parent page. We ...

Why am I encountering this export issue while attempting to integrate a NextAuth.js Provider with Next.js?

Embarking on my first project in React/Next.js, I opted to employ NextAuth.js for authentication. Following the initial steps outlined in the Getting Started guide provided by NextAuth, I have successfully set up a [...nextauth].js page featuring the code ...

Make changes to the DOM element before it finishes loading

Is it possible to manipulate an object in a DOM before it's fully loaded? I am attempting to adjust the following object: (function (g) { var d = document, i, am = d.createElement('script'), h = d.head || d.ge ...

When utilizing MUI's ThemeProvider, it may result in encountering errors that display as "undefined"

I am facing an issue with my MUI application. Everything was working perfectly until I decided to implement a ThemeProvider. It seems that as soon as I add the ThemeProvider, the application breaks and all MUI components I'm using start throwing undef ...

I require the use of Nodejs with the gm module to process images, but it is essential that it

There are two methods to consider, but I am struggling to make it synchronous. Despite attempting to use Promise.all to synchronize the process, I am faced with the challenge of images processing asynchronously and inability to reject or resolve in a loop. ...

Unable to access the length property of an undefined variable in a Node.js environment

const cities = require('./cities'); const { places, descriptor } = require('./seedHelpers'); const Campground = require('../models/campground'); const { length } = require('./cities'); mongoose.connect('mongodb ...

Unusual Behavior of HTML Email in Outlook Platform

Hello everyone! I've encountered a simple HTML table issue in an email where the last cell in thead/td is not displaying the background color - it's coming out as white. I'm completely stumped as to why this is happening, as it only seems t ...

The concept of nested labels: defining conditions for displaying specific sections of a label

Let's say I have a label that contains the following text: <label>This is a text. This is another text.</label> Is there a way to indicate that the second sentence should only be visible when a boolean value is true? For example: <la ...

The 600 pixel wide page is not completely filling the 640 pixel width screen on a mobile device

Currently, I am conducting a test on a webpage using an iPhone 5s with a screen resolution of 1136 x 640 pixels. The meta tag is set as follows: <meta name="viewport" content="user-scalable=yes, initial-scale=1, width=device-width, shrink-to-fit=no"&g ...

Turn off or delete CSS3 transitions once the :active pseudo-class is activated

I find myself in a common situation: I have a button that changes color with a transition when hovered over using the :hover pseudo-class. Additionally, the button has a :active triggered class that results in another color change when clicked on; however, ...

What is the method for sending communications to pdb using node.js?

I am currently working on developing a node.js application that incorporates a Python debugger GUI. The approach I am taking involves my node.js application calling a Python file with pdb.set_trace(). While I have managed to use node.js to spawn a child pr ...

Retrieve the username from one table and insert it into a different table

Learning PHP has been quite a challenge for me today. I've been trying to pull information from a user's database into a file and then use it in a form to insert into another table. My issue is with getting the user's ID and username. I suc ...

Is there a way to utilize the child component's method?

I am looking to access a child component's method from the parent in Vue.js. To achieve this, I plan on using $refs. Code Example: <template> <div>Parent!</div> </template> Script: <script> Vue.component('c ...

Tips for isolating the month values from the res.body.results array of objects with the help of JS Array map()

Looking to adjust the custom code that I have which aims to extract months from a string using regex. It seems like I'm almost there but not quite hitting the mark. When checking the console log, I am getting "undefined" values for key/value pairs and ...

What is the method of duplicating an array using the array.push() function while ensuring no duplicate key values are

In the process of developing a food cart feature, I encountered an issue with my Array type cart and object products. Whenever I add a new product with a different value for a similar key, it ends up overwriting the existing values for all products in the ...

Is it necessary for the URL of Ajax's $.post function to be identical to the URL specified in the web

I need to transfer data from my JavaScript code to a servlet. My JavaScript file is located in the webapp\secure folder, while the servlet is in the java\com\servlet folder. After researching, I found out that I can use AJAX to send data. T ...