Container-wrapper unable to contain images, overflowing despite using overflow:hidden property

I am currently working on a unique section for a website that includes a .container-wrapper element consisting of text and multiple images. The container is set to have overflow: hidden; in order to prevent any overflow issues. However, the images within the .images-wrapper are still overflowing beyond the boundaries of the container.

Here is a simplified version of the HTML and CSS structure I am working with:


<section class="custom-section">
  <div class="container-wrapper">
    <!-- Text and other content -->
    
    <div class="images-wrapper">
      <img src="image1.jpg" alt="Image 1">
      <img src="image2.jpg" alt="Image 2">
      <img src="image3.jpg" alt="Image 3">
    </div>
  </div>
</section>



.custom-section {
  position: relative;
  width: 100%;
  height: 650px;
}

.custom-section .container-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.custom-section .images-wrapper {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  display: flex;
  gap: 30px;
}

.custom-section .images-wrapper img {
  width: 300px;
  height: 430px;
}


Even though overflow: hidden; is applied to .container-wrapper, the final image in .images-wrapper is still visibly overflowing. I have double-checked the widths and positioning, and everything appears to be in order.

What could be causing this issue? How can I ensure that overflow: hidden; effectively conceals the overflowing images within .container-wrapper?

This is the current look of the section:

Current Section Appearance

Answer №1

Without specifying a width for .container-wrapper, the overflow: hidden property will not take effect. To address this, simply add a max-width like this:

.custom-section {
  position: relative;
  width: 100%; 
  height: 650px; 
}

.custom-section .container-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    max-width: 1100px; /*Include this line to set maximum width*/
}

.custom-section .images-wrapper {
  width: 100%; 
  height: 100%; 
  position: absolute;
  left: 0; 
  display: flex;
  gap: 30px;
}

.custom-section .images-wrapper img {
  width: 300px; 
  height: 430px; 
}
<section class="custom-section">
  <div class="container-wrapper">
    <!-- Text and other content -->

    <div class="images-wrapper">
      <img src="https://picsum.photos/200/300" alt="Image 1">
      <img src="https://picsum.photos/200/300" alt="Image 2">
      <img src="https://picsum.photos/200/300" alt="Image 3">
      <img src="https://picsum.photos/200/300" alt="Image 4"><!-- for illustration only-->
    </div>
  </div>
</section>

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

Clicking 'Back to Top' within an accordion

On my webpage, I have two scrolls present. One is clearly visible on the page (not loaded with ajax), while the other one is located inside an accordion. Both of them share the same class names. I want these scrolls to always be positioned at the top. I&a ...

Strategies for preserving context throughout an Ajax request

In my project, I am looking to implement an Ajax call that will update a specific child element within the DOM based on the element clicked. Here is an example of the HTML structure: <div class="divClass"> <p class="pClass1">1</p> &l ...

unable to display images from a folder using v-for in Vue.js

Just getting started with Vuejs and I have two pictures stored on my website. The v-for loop is correctly populating the information inside databaseListItem. The path is /opt/lampp/htdocs/products_db/stored_images/cms.png https://i.stack.imgur.com/969U7.p ...

Tips for customizing the mx-fluity navbar code to create multi-tiered dropdown menus

I have limited experience in web design and struggle with understanding CSS code. Can anyone provide guidance on how to create a (multi-level) menu in the popular mx-fluity blogger template that will display consistently on both PC and mobile browsers? T ...

creating unique icons in primefaces

I attempted to create a new icon for my p:commandButton, but unfortunately, I was unsuccessful. I followed the method outlined in this helpful link: PrimeFaces: how can I make use of customized icons? However, this approach did not work for me. Below i ...

Displaying individual attributes of objects through v-for loop

I have created a table-making component to streamline the process of creating multiple tables. Each table consists of three key elements: The object (an array of objects with one row per object) Headers specific to each table The object properties that n ...

- Determine if a div element is already using the Tooltipster plugin

I have been using the Tooltipster plugin from . Is there a way to check if a HTML element already has Tooltipster initialized? I ask because sometimes I need to update the text of the tooltip. To do this, I have to destroy the Tooltipster, change the tit ...

The command `grunt.option('force', true) isn't functioning properly

After reviewing the grunt.options documentation, my initial expectation was that I could initiate a Grunt task programmatically with the force option activated in this manner: var grunt = require('grunt'); grunt.option('force', true); ...

CSS: Position an element based on the size of the screen

I'm currently developing a program that will dynamically resize elements based on the viewer's screen size. The program is being built using JSP/SQL/XHTML/CSS, and I have a couple of queries. Is there a way to select a CSS file by storing the sc ...

Dealing with jQuery's scrollTop viewport problem: Adding a personalized value to position().top

I'm currently working on a single-page WordPress site. Since it's all contained on one page, I've implemented jQuery scrollTop to animate the menu when clicked. However, I am facing an issue where the fixed menu is overlapping the content of ...

Choose a specific "field" from a Firebase array

I am currently working on a project using AngularJS and Firebase, and everything seems to be functioning well. https://i.sstatic.net/ojy2Z.png However, I am facing a challenge of extracting only temperature values into one array and humidity values into ...

Exploring the world of typescript with the power of ts-check

I'm having trouble figuring out how to work with a generic function using TypeScript's new ts-check feature. /** * @type {Reducer<IPoiState, any>} */ const poi = handleActions({ [ADD_BOOKMARK_START]: (state) => { return { ...sta ...

What is the reasoning behind the "open in a new tab" function triggering a GET request?

Check out this HTML tag: <a href="#" id="navBar_navBarInput_3_subNavDropdownInput_0_subNavLinkInput_0" onclick="redirectPost(4,'EntryData.aspx');">My Cool Link</a> The Javascript function "redirectPost" function redirectPost(id, ur ...

Extract the color of an individual character

There is a code snippet in JavaScript using p5.js that functions as a video filter: const density = ' .:░▒▓█' //const density = ' .tiITesgESG' //let geist; let video let asciiDiv let playing = false let ...

Presentation and selection list

Here is the CSS code I am using: .nav li a { background-color:#000; color:#fff; text-decoration:none; padding:10px 15px; display:block; } .nav > li { float:left; } .nav li a:hover { background-color:#4db4fa; } .nav li ul { ...

Show a toast message and reset the form upon submission

Here I have created a contact form using HTML, CSS, and JavaScript. However, I'm facing an issue where the form redirects me to a page displaying the submitted details after clicking the submit button. I want to display a toast message instead and res ...

invoking an API within a map function and utilizing the response

vm.owners = parents.children.map(function(e) { getparentById(e.Id) .then(function(getresponse) { var parentLink = '<a href="/#/parent/onboard/' + e.Id + '" target="_blank">' + e.Number + "-&qu ...

I'm confused about why the PHP contact form is displaying an error message instead of sending the message

Hello there, I'm having trouble understanding why I'm receiving a message about not having permission to use a script from another URL when I fill out this form. The expected behavior would be for the form to thank me and then proceed to send a ...

Display a jQuery loading window

Need help with displaying a loading div when making an ajax post request. I've tried the following code but it's not working. Can someone please assist in resolving this issue? $(document).ready(function() { $('a.pagerlink').click( ...

Using jQuery to target the element before

Is there a way to determine the width of elements located before an element when it is hovered over? I attempted to achieve this using the following code: $('ul li').hover(function() { $(this).prevAll().each(function() { var margin = $(this ...