Using CSS3 to conceal overflow when applying a transform effect

I am attempting to create a basic CSS3 hover effect on an image. My goal is to have half of the image appear transparent when hovered over. For demonstration purposes, I have set it to black.

<div class="section">
    <img src="http://placekitten.com/110/155" />
    <div class="efx" />
</div>

.section{
    width:700px;
    background-color:orange;
    height:170px;
    position:relative;
    margin:50px;
}

.section:hover .efx{
    height:155px;
}

img{
    width:110px;
    height:155px;
}

.efx{
    overflow:hidden;
    background-color: black;
    z-index: 10;
    left: -51px;
    position: absolute;
    height: 0px;
    width: 105px;
    transition: all .5s ease-in;
    transform: skew(35deg, 0deg);
    bottom:15px;   
}

If you view the Fiddle here http://jsfiddle.net/5ST86/ you can see the current result. Below is my desired outcome.

Answer №1

To fix the issue, simply include overflow:hidden in the styling for the section element.

Check out this jsFiddle demo for reference

.section{
    width:700px;
    background-color:orange;
    height:170px;
    position:relative;
    margin:50px;
    overflow:hidden;
}

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 there a way to apply border-radius to the header of a table in Bootstrap 5?

My use of Bootstrap 5 for styling a table has encountered an issue. Even with the border-radius set on the table-dark class, the thead element's border does not change. I am looking for a way to address this problem. Any suggestions? .table-dark { ...

An innovative tool for discovering how different colors will complement each other

Design may not be my strong suit, but there are times when I need to add a border line or a shade of gray to a background color. Is there a tool available where I can specify background color: #343434 color: #asdfgh and visually see how it will look wit ...

What is the best approach to automatically expand the side drawer when fetching data from an API?

I'm currently tackling a project to create a bookshelf. As someone who is still learning the ropes of programming, I have successfully implemented the Google Books API. However, I am facing an issue where my side drawer (side menu) fails to expand onc ...

What is the best way to limit the dimensions of a responsive Google ad?

I have been using this responsive Google ad code on my website to display ads. <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display ...

Using justify-content-between in a div container with only two items will not produce the desired effect

I'm having trouble aligning two elements on opposite ends of a div container using Bootstrap's justify-content-between class. The h4 element is not on the left and the button on the right as expected. I am using Bootstrap 5.2.3. Can anyone help m ...

Issue with CSS causing elements to display improperly within nested grids

I am facing an issue where I want to nest a grid within another grid, but the elements in the nested grid are not appearing in the order I desire. Specifically, I would like the "#classes" section to be at the bottom of the nested grid, but it remains stuc ...

Aligning text of different sizes vertically in CSS

Struggling with a text line that contains multiple font sizes? Want all the text to align with the middle of the .line1 element? I tried using vertical-align:middle, but it's not working as expected. Check out the code on JSfiddle: http://jsfiddle.net ...

The movement of the Bootstrap navbar brand causes a shift in adjacent elements

Is there a way to use the bootstrap navbar brand without it affecting the layout of other elements? I'd like to have the icon aligned to the left and the navbar elements perfectly centered. Alternatively, is there a way to include the element as a n ...

Concealing Bootstrap 3 elements on a split-screen layout

I encountered a peculiar issue with Bootstrap 3. When I resize my browser width to half the screen, there is a slight 1px threshold where both "hidden-xs" and "hidden-sm" elements become visible simultaneously. Is there a way to fix this so that only one o ...

The height of the Material UI dropdown is displaying in an improper manner

I'm currently experimenting with the Material UI dropdown on my website, utilizing the react-select library. However, I've encountered an issue where the UI gets compromised when using an option that exceeds the width of the dropdown. If anybody ...

The issue with grunt-contrib-compass not functioning properly within npm

I recently installed npm and grunt, followed by installing grunt-contrib-compass. However, when I try to run grunt, I encounter the following error: Running “compass:dist” (compass) task Warning: not found: compass Use –force to continue. Aborted du ...

Setting up a specific print media query for the body element through JavaScript

I'm facing an issue with my web page that has a bootstrap modal which pops up when a button is clicked. I've added a print media query to print the content of the modal, but it's causing a problem. When I include the media query in the CSS, ...

What is the best method to determine when 20% of a "<section>" element is within the user's view?

Looking at the layout, I have two sections that take up the entire page. My goal is to detect when the second section is 20% visible while scrolling, and then smoothly scroll to lock that section in place so it occupies the full space. This action should a ...

Is there a way to have a div element with a box-shadow effect on top of its h1 child element?

I am facing an issue where a div with a box-shadow and an h1 inside are not aligned properly, causing the shadow to not cover the h1 element. Below is the code snippet in question: h1 { position: absolute; top: 50%; left: 44%; -webkit-t ...

Ways to make video controls visible following the initial click on the video

I have a collection of videos on my website and I would like them to display with a poster (thumbnail image) initially. The video controls should only appear once the user clicks on the video for the first time. Therefore, when the page is loaded, the cont ...

Is there a way to synchronize the autohide duration for both the LinearProgress MUI and SnackBar components?

Can someone help me align my SnackBar with the LinearProgress so that they both have an auto-hide duration of 4 seconds? I've been struggling to figure it out for hours and haven't found a solution yet. Could the issue be in the useEffect part of ...

Leveraging the @font-face feature along with fonts sourced from fontsquirrel

As I embark on creating my very first website, I find myself delving into the world of fonts from Font Squirrel. However, a challenge arises as I realize that not all the fonts I downloaded from the site are easy to use. The real struggle comes when deal ...

Steps for modifying an element in an array using Javascript

Currently, I am a beginner in the realm of JavaScript and I am trying to build a todo-style application. So far, I have successfully managed to create, display, and delete items from an array. However, I am facing challenges when it comes to editing these ...

How can you create a jQuery fade in effect for a single <li> element

I'm in the process of developing a task management app that generates a new li element every time a user adds an item. However, I am facing an issue where fadeIn() is activating for every li on the page whenever a new item is added. Does anyone have s ...

Tips on utilizing CSS for text transformations

I'm currently working on a web app where I am using the CSS "transform" property to rotate text by 90 degrees on large and desktop screens. However, I would like the rotation angle to automatically change to 0 degrees if the screen size is small. Can ...