Behold the magic of a three-column layout with sticky scroll behavior and an absolute

I am struggling with a layout that involves 3 columns, each with its own independent scroll. The first column contains an absolute element that should overflow on the x-axis, but I am having trouble getting the overflow-x:visible property to work when combined with overflow-y:auto.

Can anyone provide assistance with this issue?

.container {
  display: flex;
}

.column2 {
  width: 60%;
  background-color: #bababa;
  height: 5000px;
}

.side-column {
  width: 20%;
  background-color: #eeeeee;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: visible;

}

.side-content {
  width: 100%;
  height: 3000px;
}

.picker {
  position: absolute;
  top: 25px;
  left: 25px;
  height: 300px;
  width: 300px;
  background-color: #f00;
}

.column3 {
  height: 100px;

}
<div class="container">
  <div class="side-column">
    <div class="side-content">
      column1
      <div class="picker"></div>
    </div>
  </div>
  <div class="column2">
    content
  </div>
  <div class="side-column column3">
    <div class="side-content">
      column3
    </div>
  
</div>

https://jsfiddle.net/burro92/nvepx7dL/

Answer №1

Avoid unnecessary use of containers...

The property overflow: auto; is effective only when the content inside the container exceeds the width or height of the container itself. In such cases, a scroll bar will be automatically added.

Consider this code snippet... HTML

<div class="container">
    <div class="column1">
      
        <p>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum aperiam, repellendus sequi debitis dolorum illo hic sed, cumque voluptatibus magnam sint architecto ullam laboriosam ipsa molestias culpa ab possimus soluta nobis omnis? Ab praesentium consectetur, est laborum voluptatem vitae, accusantium cum odio voluptates consequatur mollitia maxime assumenda sapiente dignissimos quo quis? Sit nulla esse deleniti odio asperiores perspiciatis, autem animi impedit quasi laborum minus labore natus delectus quaerat dolorem. Soluta tempora animi id quo recusandae nulla, cupiditate itaque voluptatem odit. Veritatis nemo quos temporibus soluta voluptas, quae facilis vel laboriosam labore. Debitis illo, harum fugiat quo laboriosam tenetur mollitia perspiciatis.
        </p>
        
      
    </div>
    <div class="column2">
        <p>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum aperiam, repellendus sequi debitis dolorum illo hic sed, cumque voluptatibus magnam sint architecto ullam laboriosam ipsa molestias culpa ab possimus soluta nobis omnis? Ab praesentium consectetur, est laborum voluptatem vitae, accusantium cum odio voluptates consequatur mollitia maxime assumenda sapiente dignissimos quo quis? Sit nulla esse deleniti odio asperiores perspiciatis, autem animi impedit quasi laborum minus labore natus delectus quaerat dolorem. Soluta tempora animi id quo recusandae nulla, cupiditate itaque voluptatem odit. Veritatis nemo quos temporibus soluta voluptas, quae facilis vel laboriosam labore. Debitis illo, harum fugiat quo laboriosam tenetur mollitia perspiciatis.
        </p>
    </div>
    <div class="column3">
     
        <p>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum aperiam, repellendus sequi debitis dolorum illo hic sed, cumque voluptatibus magnam sint architecto ullam laboriosam ipsa molestias culpa ab possimus soluta nobis omnis? Ab praesentium consectetur, est laborum voluptatem vitae, accusantium cum odio voluptates consequatur mollitia maxime assumenda sapiente dignissimos quo quis? Sit nulla esse deleniti odio asperiores perspiciatis, autem animi impedit quasi laborum minus labore natus delectus quaerat dolorem. Soluta tempora animi id quo recusandae nulla, cupiditate itaque voluptatem odit. Veritatis nemo quos temporibus soluta voluptas, quae facilis vel laboriosam labore. Debitis illo, harum fugiat quo laboriosam tenetur mollitia perspiciatis.
        </p>
      
    </div>
</div>

CSS

.container{
    display: flex;
}


.column1{
    width: 20%;
    height: 300px;
    background-color: rgb(211, 210, 210);
    overflow: auto;
}

.column2{
    width: 60%;
    height: 300px;
    background-color: rgb(255, 255, 255);
    overflow: auto;
}


.column3{
    width: 20%;
    height: 300px;
    background-color: rgb(211, 210, 210);
    overflow: auto;
}

Output

A scroll bar will be included automatically when required. If you prefer a scroll bar on a specific axis, simply change overflow: auto; to either overflow-y: auto; or overflow-x: auto;.

Avoid using overflow: scroll; as it will always display a scroll bar irrespective of whether it is necessary or not. Hence, refrain from using this method.

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

I'm facing an issue where TailwindCSS fails to stretch my VueJS application to full screen width

My components are all contained within a div with classes flex-row, w-screen, and content-center. However, when I switch to reactive/mobile mode on the browser, it only takes up about 2/3 of the screen and doesn't fill up the remaining space. Below i ...

Shifting Divs/Text while adjusting zoom levels in HTML/CSS with Bootstrap

As a newcomer to the coding world, I am encountering an issue with my Navbar. Everything appears fine at 100% zoom on the browser, but when I zoom in to 150%, everything becomes jumbled. How can I ensure that everything stays the same size regardless of zo ...

Choosing the attribute value using jQuery/CSS

Looking for a way to retrieve attribute value using jQuery/CSS <dt onclick="GomageNavigation.navigationOpenFilter('price-left');"> I tried using $("dt[onclick='GomageNavigation.navigationOpenFilter('price-left')']") bu ...

Having trouble with the Three.js OBJ loader in CodePen?

Currently, I am experiencing a challenge with loading an OBJ file on Three.js. Oddly enough, the functionality seems to be working perfectly fine when I deploy the files on my server as demonstrated here: However, when attempting to run it on Codepen, I e ...

How to retrieve a value from an Angular form control in an HTML file

I have a button that toggles between map view and list view <ion-content> <ion-segment #viewController (ionChange)="changeViewState($event)"> <ion-segment-button value="map"> <ion-label>Map</ion-label> & ...

What steps can I take to ensure that this code is validated prior to proceeding to the subsequent page?

I am experiencing an issue with this HTML fieldset form code. When I click the submit button, it redirects to the next page. However, if I remove "next" from the button class, the form validates but does not proceed to the next page. Can you please help me ...

Is it possible to personalize a select button for both iOS and Android mobile platforms?

I've implemented a dropdown on my website for the desktop version and it works fine. However, I want to replace this dropdown with a select button on iPad and iPhone, as I prefer how it looks on those devices. Is it possible to style the select butto ...

Using Laravel to connect custom fonts

After previously discussing and experimenting with linking custom font files in Laravel, I encountered an issue where the fonts were not displaying correctly on my website. Due to Laravel's router, directly linking to font files in CSS was posing a ch ...

The web server experiences a layout and functionality breakdown caused by an issue with the config.js file following the uploading process

I recently created a website. However, when I uploaded it to my hosting company's server and tested it on different browsers, the layout appeared broken. Some of the CSS files loaded properly, but certain elements and styles were not in their correct ...

The inclusion of the <div> tag disrupts the functionality of the Material UI Grid

While attempting to enclose my element within a <div> that is nested inside the <Grid>, I realized that this was causing the <Grid> layout to break! Surprisingly, when I tried the same approach with Bootstrap grid system, this issue did n ...

Update D3 data, calculate the quantity of rows in an HTML table, and add animations to SVGs in the final

Attempting to update data in an HTML table using D3 has proven to be quite challenging for me. My task involves changing the data in multiple columns, adjusting the number of rows, and animating SVG elements in each row based on new data arrays. Despite tr ...

PHP bug causing inaccuracies in output results

I've written a PHP script to determine a student's final grade, taking into account weight and target grades. However, the output value it generates is incorrect. Below is my current PHP code: <?php $numassignments = isset($_GET['numass ...

What is the best way to trigger an event function again once a specific condition has been satisfied?

I'm currently working on a project where I need a sidebar to scroll at a slower rate until it reaches a specific point, and then stop scrolling once that point is reached. Below is the jQuery code I've been using: $(window).on("scroll", function ...

Here is a guide on determining the date variance in PHP by leveraging jQuery

I have been attempting to use the jQuery change function to calculate the variance between two dates, but I am encountering a problem as the code seems to be running smoothly without returning any results... <input type="text" name="datte1" class="form ...

Navigate to the top of the page using jQuery

Attempting to implement a simple "scroll jump to target" functionality. I've managed to set it up for all parts except the "scroll to top". The jumping works based on the tag's id, so it navigates well everywhere else, but not to the very top. He ...

What is the process for creating a hover effect on a button that is triggered when a user hovers over the button's parent container?

Visit this link to view the code My Goal: I want the hover effect that normally applies to buttons when hovered over, to instead be applied when a user hovers over the parent div containing those buttons. The parent divs in question have a class of "ser ...

How can I connect the box using the Interactive Picture jQuery tool?

When using the Interactive picture jQuery, I have the following code snippet within my document: jQuery(document).ready(function(){ $( "#iPicture6" ).iPicture({ animation: true, animationBg: "bgblack", animationType: "ltr-slide ...

I am currently dedicated to enhancing my background transitions and experimenting with creating smooth fade-ins

I'm almost done with my Weather Forecast page for the FCC challenge. However, I'm not satisfied with how the code for swapping the background works. It just doesn't feel right to me. Unfortunately, I can't figure out how to fix it. Addi ...

Build desktop-style applications using a unique user interface library and integrated development environment designed specifically for HTML, JavaScript

I am looking to create a desktop application using HTML, JavaScript, and AJAX for the purpose of making it available on multiple platforms. I was wondering if there is a UI library and web IDE similar to WebOS Enyo that I can use to build my HTML/AJAX app? ...

Struggling to Align Banner in Dynamic Layout

I am currently working on centering the banner image as the resolution size decreases, rather than having it pushed to the right. The specific page I am addressing can be found here. My approach involves utilizing a width of 100%. <!-- BEGIN T ...