What causes the images in an overflow: hidden container to grow in size when hovered over?

When my images are hovered on, I want them to stay within the container without overflowing, which is why I have used overflow: hidden. However, the issue is that it causes the bottom of the container to expand and interfere with the content below. How can I prevent this from occurring?

View code example on Code Pen

.image-hover-container {
    width: 50%;
    border-radius: 3px;
    overflow: hidden;
    display: block;
    margin: 0 auto;
    margin-top: 20px;
    transform: translate3d(0,0,0);
}

.inner-container img {
    width: 100%;
    border-radius: 3px;
    transition: all .4s ease-in;
}

.image-hover-container img:hover {
    transform: scale(1.1,1.1);
}

p {
    text-align: center;
    font-family: arial;
}

Answer №1

To prevent overflow, apply the style overflow: hidden to the .inner-container class.

.inner-container {
    overflow: hidden;
}

.image-hover-container {
 
  width: 50%;
   border-radius: 3px;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  margin-top: 20px;
  transform: translate3d(0,0,0);
  
}

.inner-container {
  overflow: hidden;
}

.inner-container img {
   width: 100%;
   border-radius: 3px;
  transition: all .4s ease-in;
/*   transform-origin: bottom center; */
}

.image-hover-container img:hover {
    transform: scale(1.1,1.1);
}

p {
  text-align: center;
  font-family: arial;
}
<div class="image-hover-container">
  <div class="inner-container">
  <img src="http://addisongabe.com/new/assets/images/store/typecouragements/preview/keep-on-exploring-preview.png" alt="Test Image" />
  </div>
  <p>Hello There</p>
  
</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

iOS 10's autofocus feature experiencing difficulties in focusing on input

While using an application on my desktop or Android device, I have noticed that the input focus works perfectly fine. However, when I try to run the same application on iOS 10 Safari, the input focus does not seem to be working. It is worth noting that I ...

When looking for a selection, the drop-down list unexpectedly shifts upwards

When using the ngx-intl-tel-input library in my Angular application, I noticed that when searching for a country in the dropdown list, it moves to the top. I am looking to fix the position of the dropdown menu while searching. Check out the demo: Demo Lin ...

Using jQuery to implement a hover event on iPhone and iPad devices

Is there a way to use jQuery to add hover effects on apple touch devices for my navigation bar? I've tried using what I have so far, but it doesn't seem to be working. Has anyone had success with this before? <script> $(document).read ...

Aligning images horizontally within individual div containers within a list

Struggling to align images horizontally, they are all stacked on top of each other. New to this and could use some assistance figuring it out! Any help would be appreciated! <div class="social"> <ul> <div class="facebook"> ...

Can you provide an explanation for the "ved" parameter used in a Google search?

I've been spending a good couple of hours trying to unravel the mystery behind the "ved" parameter in Google search results. Curiosity always gets the best of me. Here's what I've discovered so far: The value of "ved" changes- 1 - for ever ...

Ways to individually select and activate several HTML elements with matching classes, and then apply styles to a different div featuring multiple classes using Jquery or JavaScript

Within my webpage, I have created a section with three links. Clicking on each link reveals specific content (content 1, content 2, and content 3). The issue arises when I have two identical sections (Section 1 and Section 2) and clicking on a link display ...

The radio button is unable to be deselected within the radiogroup due to the presence of a

I have developed a customized radio button component and want to group them together. However, when I utilize a v-for loop to display multiple radio buttons, they do not deselect when another option is selected. This is the code template for my radio butt ...

Position the image in the exact center both vertically and horizontally

I am trying to center a list of images both vertically and horizontally within their respective li. I want to achieve this using jQuery. How can I align the images in the center of each li element both horizontally and vertically? You can view a demo at c ...

Create a child element to match the width of its grandparent element

Would it be possible to make the innermost div as wide as the section in my nested structure? Below is a snippet of the code: body { margin: 0 auto; padding: 0; background-color: blue; } #content { background-color: orange; padding ...

Using Node JS to serve an HTML file along with cascading style sheets

As I delve into pure node.js, I encountered an issue related to the HTTP protocol. After spending hours searching and testing my code, I finally managed to serve my HTML page with CSS successfully. Take a look at my code snippet below: const server = http ...

What is the best way to position three SVG files in the center of a webpage?

I want to combine three separate SVG files to create one single graphic. The first SVG file is a red triangle, the second is a blue circle inside the triangle, and the third is a purple rectangle beneath the triangle with a little space in between. My obje ...

Ensuring the Angular Material bottom sheet (popover) stays attached to the button

Recently, I've been working on an Angular project where I successfully integrated a bottom sheet from Angular Material. However, I encountered an issue when trying to make the opened popup sticky to the bottom and responsive to its position, but unfor ...

Vue calendar - The month display is condensed to only one row

Currently, I am incorporating bootstrap-datetimepicker for Vue (found at https://www.npmjs.com/package/vue-bootstrap-datetimepicker) via CDN. The date display looks good, however there is an issue with the month view size when selecting a month. https://i ...

Struggling to make input:checked feature function properly

I'm in the process of developing a product page and I'd like to implement a feature where clicking on the Buy button triggers a pop-up menu to appear. I've been attempting to use the Checkbox hack to achieve this but have encountered some di ...

How can I modify the text that appears when hovering over an element?

Can the displayed text be altered on mouse hover? For instance, can I change the text of a H1 tag when hovering over it using HTML, CSS, and JavaScript? ...

Achieving a slanted line in full screen using bootstrap

Currently, I am working on creating a slanted line that stretches across the entire page. However, there seems to be a small gap on both the left and right margins of the line. Here is the HTML code: <div class="container-fluid"> ...

What might be causing Flex not to function properly on my personalized landing page?

I attempted to create a basic landing page featuring an image background with a logo, button, and a row of 4 images displayed side by side using Flex. However, for some reason, the Flex is not functioning properly for the row of images. Here is the code s ...

Retain user inputs across multiple fields upon form submission

After submitting a multiple field input, I want to retain the input values. Is there a way to achieve this using PHP or possibly another language? Here is an example of the input: <input type="text" name="passport[]" class="form-control" aria-describe ...

Bing Webmaster Tool identifies excessive HTML size on your website

After running a site scan using the Bing Webmaster Tool, I discovered that some of my pages contain the issue of "Html size is too long". One specific example is this page: I am unsure how to address this issue. According to Bing, it could be due to the w ...

inept java script circle

Each image in the array is superimposed on one another to form the final picture. However, a problem arises when all the images are loaded - the loop continues to run making it extremely difficult to scroll or execute any other animations. function map( ...