Hide overflow for images with unique shapes

Here are the two image layers:

https://i.sstatic.net/lUUQC.jpg

One shows a hand holding a phone, and the other is a black hole.

This is how you can achieve it using HTML markup:

<div class="wrapper">
  <img class="wrapper__image" src="path/to/image.png">
</div>

And here's the SCSS code for styling:

.wrapper {
  background: url("path/to/blackhole.png") no-repeat center bottom;
  width: 528px;
  height: 600px;
  overflow: hidden;

  &__image {
    margin-left: 60px;
    margin-top: 5px;
  }
}

The challenge arises from the rounded corners on both images. If we push the hand image below the edge of the wrapper div to hide it in the black hole, there will be visible gaps at the bottom due to the rounded shapes.

Is there a way to strategically position the hand image below the black hole without revealing any transparent corners?

https://i.sstatic.net/gdaKl.png

If the black hole were square instead of round, this issue could be easily resolved.

The goal is to create an illusion of the hand with the phone sliding down into the black hole seamlessly.

Answer №1

To achieve the desired effect, I recommend using pure CSS to create a hole that mimics your image.

When you hover over the hole, you will see the effect. Simply adjust the coloration to match your specific image.

.hole {
  width: 300px;
  height: 300px;
  position: relative;
  z-index: 0;
  overflow: hidden;
  border-bottom-right-radius: 50% 50px;
  border-bottom-left-radius: 50% 50px;
}

.hole::before {
  content: "";
  position: absolute;
  z-index: -1;
  height: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 100%;
  background: radial-gradient(farthest-side at top right, grey, black);
}

img {
  position:absolute;
  top:0;
  left:100px;
  transition:2s all;
}
.hole:hover img {
  top:100%;
}
<div class="hole">
  <img src="https://picsum.photos/100/200?image=1069">
</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

Is it possible to use a full-width material-ui Button inside a Badge component?

Within a grid, I had initially used fullWidth on a Button to make it expand and fill the container. Everything was functioning correctly until I enclosed the Button in a Badge element. Now, the fullWidth property is not being applied, and the button rever ...

Try triggering transitions on all elements by hovering over any CSS element

I am currently in the process of developing a website, and for the header section, I have decided to use a table format where each column represents a different section. The top row will feature a picture link, while the bottom row will display the name of ...

A guide to integrating Tailwind UI animations into pure HTML and JavaScript

I am struggling to implement the animation part of tailwindui.com components that I want to use. The instructions are provided in the comments, but I'm having trouble integrating them into my code. I prefer not to rely on any frameworks or libraries a ...

Make the element switch from hidden to visible when hovering over it using CSS

I had a challenge to only show some rating text on my website when I hovered over it. Being new to coding with CSS and JavaScript, I was experimenting with overriding styles using the Stylebot extension in Chrome. I encountered an issue while trying to mo ...

Trouble with Materialize CSS: Form elements displaying incorrectly

I attempted to implement a login form within a modal, following the example provided here (https://codepen.io/skcals/pen/bxdpaN). However, when I applied the same code to my own website, this is how it appeared: Has anyone else encountered this issue? And ...

Why dashes are incompatible with inner <span> elements?

Is there a way to make hyphens work on text with <span> elements for highlighting without breaking the algorithm? I don't want a workaround like &shy;. https://i.sstatic.net/JGl1M.png The Code (sandbox: https://codepen.io/anon/pen/ayzxpM): ...

Is there a way to utilize JavaScript in order to trigger a CSS animation to occur at a designated time during a video

I have a cool animated image element that I want to play at a specific point in time during a video using JavaScript. I'm not sure how to make it happen, but I know the .currentTime property could be the key. My goal is for the animation to only play ...

Unable to see background image inside div

Why is the background image not showing up in the left column? I've applied the CSS background-image to .left but it's still not working. Any suggestions on what might be causing this issue? It seems like a small problem, but it's really bot ...

Reaching SVG with CSS

Is it possible to target SVG elements with CSS? In older versions of IE, they display like broken images and I want to hide them using modernizr. I'm looking for a solution like the following... .no-svg object[type=svg] { display:none; } I have be ...

Lose the scrollbar but still let me scroll using the mouse wheel or my finger on the fullscreen menu

I am currently working on a fullscreen menu design. However, when the menu appears, some elements are not visible unless I apply the overflow-y: scroll property to the menu. But I don't like the appearance of the additional scrollbar that comes with i ...

The enigmatic appearance of CSS border-image using a transparent image creates a visible edge when viewed

My website, located at , features a unique design element created using the CSS border-image property and a .png image with a transparent edge, giving the appearance of torn paper on the divs. However, I have encountered an issue specifically on my Android ...

Creating a dynamic grid design with images using the <ul><li></li></ul> HTML tags

Trying to create a responsive grid of images that adapts to changes in browser size. Is there a way to achieve this using a list? Ideally, I want the images to be evenly spaced in rows. For example, if there are three rows of four images on top and one r ...

The background video on the website is having trouble resizing properly to fit the screen dimensions

I'm new to coding and I'm attempting to incorporate a background video on the homepage. The issue arises when I resize my window or view it on a mobile device, as the video fails to adjust to the window size, causing side scrolling that reveals t ...

Ways to customize easypiechart appearance with CSS styling

I am looking to create a circular counter similar to the one shown below. I have tried using easy-pie-chart but I am unsure how to style the circles to look like the example provided. Is there a way to achieve this through CSS? Any recommended resources o ...

Having trouble with setting the margin-top of a div?

When I attempted to apply the margin-top property to a div's style, it didn't have any effect. https://i.stack.imgur.com/jyY2G.png Below is the code snippet: .side { margin-left: 65%; margin-top: 3%; margin-right: 3%; border: 1px sol ...

Should the event happen inside a div section

How can I determine if an element is currently positioned within a specific div? I am working on a vertical scrolling menu where the height of the navigation div is set and overflow is hidden to show only a portion of the links at a time. To navigate thr ...

How can I use jQuery to vertically align an element?

Here's my website: Take a look here! I have a menu on the left column that I want to center. Take a look at the image below for a better understanding of what I'm trying to achieve. https://i.stack.imgur.com/ZzprT.png Here is the JavaScript c ...

Safari now fully embraces Flexbox technology

My flexbox code works well in Chrome and Firefox, but unfortunately it's not performing well in Safari. Despite trying various prefixes, I couldn't achieve the same simple order. How can I modify or add to my code so that it functions normally in ...

Eliminate unnecessary space from a Bootstrap 4 Card

Using the Card class from Bootstrap 4, I'm struggling with an extra space on the right side: https://i.sstatic.net/5qb8y.png (Please ignore the 'porno' thing, haha). You can clearly see the extra space on the right. I've been attemp ...

Display flash messages consistently in a designated area on the webpage instead of appearing at the top of the page in Flask

{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} <div class="alert alert-{{ category }}" style=" ...