How can I activate horizontal overflow within a vertically scrollable container?

I created a CSS layout using TailwindCSS to showcase my current issue. While I used Tailwind Playground for quick layout building, feel free to provide your solution using plain CSS.

Here is the code and result: https://play.tailwindcss.com/8xynVWIRC7

For those unable to visit the link, here is the structure:

<div class="grid grid-cols-4 gap-0 h-screen w-screen overflow-hidden">
  <div class="h-screen col-span-1 bg-gray-300 p-6 space-y-6 overflow-y-scroll overflow-x-visible">
    <div class="h-36 bg-gray-400 rounded-lg drop-shadow-md"></div>
    <!-- more code -->
    <div class="h-36 bg-gray-400 rounded-lg drop-shadow-md"></div>
  </div>
  <div class="col-span-2 bg-gray-100"></div>
  <div class="h-screen col-span-1 bg-gray-300 p-6 space-y-6 overflow-y-scroll overflow-x-visible">
    <div class="h-36 bg-gray-400 rounded-lg drop-shadow-md"></div>
   <!-- more code -->
    <div class="h-36 bg-gray-400 rounded-lg drop-shadow-md"></div>
  </div>
</div>

Now, let me explain the issues I am facing:

In the displayed image, there are sidebars on both left and right sides, with a central content area. The sidebars need to be vertically scrollable due to their content exceeding the screen height.

Issue #1: I want the contents within the sidebars to overflow horizontally outside the sidebar when necessary (especially visible in hover states). Currently, the contents do not overflow outside their parent element (sidebar) because of the "overflow-y-scroll" class I added for vertical scrolling. Removing this class allows horizontal overflow but sacrifices the scroll feature. How can I achieve horizontal overflow while maintaining vertical scroll?

Issue #2: The contents in the right sidebar attempt to overflow to the right instead of towards the main content area (to the left). Using "direction: rtl;" changes the direction of child elements, which does not solve the problem. What approach should I take to correct this issue?

Thank you!

Answer №1

Personally, I have yet to explore tailwind CSS in depth. However, when it comes to styling with CSS, I might be able to offer some assistance. Have you considered including overflow-x: auto; for the main parent element (the sidebar)? Additionally, adding padding on both the right and left sides can help the content naturally align towards the center.

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

Loading JS and CSS files in relation to the website root directory

When it comes to including CSS/JS files, what are the best practices for defining the file URI? Some people prefer to include files relative to the website root by specifying the full URI: <link rel="stylesheet" href="/my/path/to/css/main.css"> Thi ...

The CSS file is not displaying the background image on the PHP file

I am facing an issue with using CSS to include a background image for the layer, but it doesn't seem to be working correctly... The CSS code snippet is as follows: header { background-image: url("boisko.jpg"); background-repeat: no-repeat; background ...

The image tag is being used to show the exact location, however, there is no

How can I load a previously uploaded image via ID in the controller? The controller passes the correct location to the view, but the view does not display the image. When I inspect the view page, it shows the correct ID and location but does not render the ...

A method for positioning each pair of <li> elements side by side

My goal is to arrange every pair of li elements next to each other (e.g. 0-9, A-B, C-D, ...). Currently, they are aligned one by one. <ul> <li class="alphabetRow"><a href="#" id="alpha_1" class="alphabet active" >0-9</a></li ...

The feature to select a cell on a Bootstrap table is not functioning as expected

Is there a way to retrieve the Cell value from a Bootstrap table when clicked? I have a method set up, but for some reason, after clicking on the table heading, the tdOnClick() function stops working. It seems to only be functional before clicking on the t ...

Creating a sophisticated form design with multiple input fields using DIV elements in HTML

I am looking to create a multi-column form layout that allows each row to have a different number of fields. My initial approach was using tables and the colspan attribute within td tags for layout structure. However, I have learned that using tables for l ...

Core-pages with polymer core have no set height limit

I am embarking on my first project using Polymer. I have implemented core-pages to facilitate navigation between different pages. However, I am facing an issue where the pages are not displaying with a white background-color as intended in the css. You ca ...

What is the reason behind loading two srcset images?

When it comes to creating responsive web templates, I make use of the srcset attribute in order to load different images based on the current viewport size. This has been working well overall. However, in production mode, the images are fetched from a Digi ...

I'm having trouble getting jquery css to function properly in my situation

I am trying to implement a fallback for the use of calc() in my CSS using jQuery CSS: width: calc(100% - 90px); However, when I tried running the code below, it seems like the second css() function is not executing. I suspect that there might be an issu ...

How can I remove the bouncing effect of the top bar in Chrome when scrolling in Three

There is a frustrating problem I am encountering on my website with the joystick control. Whenever I try to move my joystick down, Chrome triggers either the refresh dropdown or the top bar bounces and goes in and out of fullscreen mode. ...

Troubleshooting: Issue with detecting keypress using jQuery

Currently, I have a jQuery script that checks password strength and changes an image source based on complexity. The functionality works smoothly within jsFiddle (set to jQuery 1.91), but when implemented on my webpage, the event seems to not be triggered. ...

Form in HTML with Automatic Multiplication Functionality in pure JavaScript

I'm struggling with integrating a simplified HTML form with JavaScript to dynamically adjust and multiply the entered amount by 100 before sending it via the GET method to a specific endpoint. Below is the HTML form: <body> <form method= ...

The issue of the selection option not being cleared after being set to 0 persists in JavaScript

I am facing an issue where I need to reset the select option to `0` when another option is selected. I have tried the code below for this purpose. if (varALPO1MobNum == "0") { var selectElement = $(&apo ...

What is the significance of the space between form.validate and .ng-invalid-email.ng-dirty?

I'm currently working on an AngularJS application and I'm confused about the spacing between "form.validate" and ".ng-invalid-email.ng-dirty" in the stylesheet code below: <style> form.validate .ng-invalid-required.ng-dirty {background ...

The problem arises when trying to use the Jquery click event on buttons that have been generated

I've encountered an issue where I can create components dynamically, but the click event doesn't seem to work on buttons that are dynamically generated. Check out the code snippet below: HTML file: <div class="merge_sections">&l ...

Bootstrap 4 rows causing dropdown clipping

I am experiencing a strange problem with Bootstrap 4 when using dropdown. I have additional actions listed in the dropdown menu that are supposed to be visible when clicking on the "plus icon". However, when I do click on the "plus icon", the dropdown ends ...

Is it time to delete a bootstrap attribute?

I have implemented a bootstrap class for ul/li items that adds a border around an li item when clicked. However, I am facing an issue where only the first list item is highlighted on all 4 sides when clicked, while the rest of the list items only have 3 ...

What is the best way to programmatically insert new rows into a table

I am currently working with the foundation 5 framework (not sure if this is relevant). I need to ensure that each CELL is treated as a distinct item/value when passing information to another page, and I am unsure of how to approach this issue. It should cr ...

Is it possible to have scrollbars on opposite sides of a div?

My table has a multitude of columns, prompting me to enclose it within a div with overflow:auto to facilitate horizontal scrolling. Currently, the scrollbar is situated at the bottom of the div. Is it possible to have two scrollbars present, one at the t ...

Breaking a line within a text area using html

As I work on creating a form to generate a PDF, I've encountered an issue with the text area. I want users to be able to input text and have it automatically create line breaks as they type, like this: https://i.sstatic.net/paF3r.png However, instead ...