Hidden items with horizontal overflow will appear when clicking on the page and dragging to the right

I have two graphics displayed on either side of my page content. As the browser/page width decreases, these items get cropped off the screen to create more space for the content. While this setup is working fine,

.page {
    height: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 960px;
}

There's an issue I've encountered - when the browser width goes below the defined min-width, the vertical scroll bar vanishes from the side of the page.

A CodePen demonstration of the problem can be found here: https://codepen.io/moy/pen/oemBEN

This happens because even though the body is within view, the .page element still abides by its set min-width property.

In order to address a previous issue, I placed the overflow settings on the .page element instead of the body. However, moving the following code to the body:

overflow-x: hidden;
overflow-y: auto;

Seems to work as intended. The side items are cropped appropriately and the vertical scroll bar remains visible in Chrome + Firefox (Mac). However, Safari (Mac) and IE (Windows) do not handle the cropping correctly.

If you resize the browser window and click on the background then drag right, you can reveal the messy cropped area of the page!

Is there a solution to this issue? Or should I accept that the vertical scroll bar will remain hidden?

Answer №1

To achieve this layout, you can utilize the flex layout feature:

Check out an example here: https://codepen.io/anon/pen/EvrXmG

  • The .container class initiates the flex layout.
  • The .img elements have a specified width and flex-basis, preventing them from growing but allowing them to shrink based on a "max-width".
  • The .wrap elements have a defined width and flex-basis, ensuring they do not shrink but can grow based on a "min-width".

As the page expands, the .img elements maintain their maximum size while the content fills in any available space.

Conversely, as the page shrinks, the content remains at its minimal width while the image elements start disappearing.

This approach may not be suitable for older browsers, but it is one of the simplest solutions for modern browsers. Check browser compatibility 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

Using the foreach loop in ASP.NET Core will result in the cards being displayed in a vertical arrangement instead of

Currently, I am utilizing a foreach loop in ASP.NET Core to iterate through data. Depending on the amount of data present, I aim to generate cards for each one using Bootstrap. The functionality is operational; however, the cards are organized vertically r ...

The cards in the Bootstrap layout stack on top of one another when viewed on a mobile screen

I have a "flipping card" and another bootstrap 4 card positioned side by side. However, when tested on a mobile screen using Chrome's dev console, the second card overlaps the flipping card and covers it completely. To provide some context, I've ...

The hover effect is not activated by the mouse movement event

I previously encountered an issue related to flickering with an absolute div when moving my mouse, which I managed to resolve by increasing the distance between my mouse pointer and the div. Now, I am working on the next phase of my project: My goal is t ...

Header appearing at the same level as post title due to overlapping

After rearranging the date header below my post title on Blogger, I encountered an issue where on the latest post, the date was overlapping with the header. Adjusting the margin or padding affected other date headers, leaving me unsure of what to do next. ...

Centering content vertically within a Bootstrap 4 table

I'm attempting to center the content vertically in this table using the align-middle class but it doesn't seem to be working. How can I get it to work? tr, td, p, a { border: 1px solid black; } <link rel="stylesheet" href="https://stackpa ...

What is the best way to effectively incorporate Ruby into the CSS attribute of a HAML %li element?

Greetings everyone, I am new to the world of development and seeking guidance from experienced individuals. I have been trying to solve a coding issue for quite some time now. I am currently enrolled in a programming course at Code Academy based in Chicago ...

What methods can be used to create a sitemap for unlinked HTML or PHP pages that do not have an index file?

Imagine a scenario where there is a directory containing 100 files, some PHP and some HTML. None of these files are interconnected or linked together, and there is no index file present. This setup exists within a shared hosting cPanel environment. The q ...

Designing a unique pagination layout for your WordPress website

Currently, I am working on a WordPress project. I have created my own template using CSS and HTML format. The implementation is going well, but I am facing difficulty integrating WP pagination design into my template. Below is the pagination code from my ...

Error in React regarding the tri-state checkbox's indeterminate state being null

I am attempting to create a triple-state checkbox in React. The functionality I'm aiming for is that each click on the checkbox will cycle through blank->checked->crossed->blank->.... After doing some research, I stumbled upon a helpful re ...

Spinning html/css content using JavaScript

Greetings! I am currently working on a demo site using just HTML, CSS, and JavaScript. Typically, I would use Ruby and render partials to handle this issue, but I wanted to challenge myself with JavaScript practice. So far, I have created a code block that ...

How to Style Your ASP.NET Website: Utilizing a Stylesheet with Visual Studio 2010

I am having trouble adding a stylesheet to the master page of my asp.net web form. I want to create an inline navigation menu at the top of the page, but I can't seem to get it working. I have created the stylesheet in the same way I would for an HTML ...

Is it possible to change the input type of 'time' to a string when utilizing ng-change in AngularJS?

Is there a way to convert a time input into a string or a timestamp for Firebase support? For instance, the code below will not function correctly due to the time input type. HTML <html ng-app='app'> <head> <script src="http ...

What is the best way to update my logo and incorporate a colored border at the bottom of my fixed header while the user is scrolling down?

After spending countless hours researching online, I've been struggling to implement header effects on scroll without using JavaScript. My goal is to achieve a simple effect where the header reduces in height, the logo changes, and a colored border is ...

List items overlapping

Recently, I have been facing a challenge while trying to develop a search form and showcase the results in a list <?php require_once ("Includes/simplecms-config.php"); require_once ("Includes/connectDB.php"); include("Inc ...

The arrangement of CSS code is crucial for it to work properly; any deviation from the correct order

I am facing a problem where I am trying to display a circular div using CSS, but it only works if the background image property is set first. Typically, this wouldn't be an issue if the image wasn't being dynamically inserted using PHP code. I ...

The number of characters can be measured in a div element that is editable

Looking to create a character counter similar to Twitter in a contenteditable div. The goal is to restrict users to typing a maximum of 140 characters. Using jQuery for character count and remaining display, but encountering an issue where the Enter key ( ...

Is the flowplayer software free for use on a production server?

Here is the URL I am implementing to stream videos on my website: I would like to know if it is permissible and cost-free to use in a production environment. ...

How can you trigger an event when a table cell is selected and a key is pressed?

In my project, I have some td elements with a class name assigned to them. My goal is to trigger a pop-up window when one of these td elements is in focus and the F9 key is pressed. Here's what I've attempted so far: $(document.body).keypress(fu ...

Using Bootstrap's collapse class with a smooth linear transition

I've been attempting to implement Bootstrap collapse with a linear effect, but have been encountering challenges. After trying different versions of Bootstrap, I found that the transitions were quite similar. I decided to go with the latest version av ...

Ways to retrieve parameters using $_GET

I am having trouble retrieving the parameter $_GET with a value that contains the character: '#'. Here is the code I am using: <iframe src="http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=<span s ...