HTML: Side panel + div with scrollable content with height equal to the size of the current page

My webpage layout includes a sidebar and main body sections with specific styling:

#sidebar {
    float: left;
    position: relative;
    width: 200px;
    padding: 20px;
}

The main body is designed like this:

#main {
    margin: 0 20px 0 260px;
}

On one of my pages, the main section has filters that need to remain fixed while displaying a large table. The table is too big for the page both horizontally and vertically. I want the table to be in a scrolling div that always expands to fit the entire page and adjusts if the page size changes. Here's how it looks currently:

<div id="sidebar">
    <div class="boxed" id="menu">
      <h2 class="title">Main Links</h2>
      <div class="content">
        <ul>
          <li><a href="/">Main page</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div>
    <div id="main">  
      <h2>Header</h2>
      <div class="filters">
        Filters go here
      </div>
      <div style="overflow: auto;">         
        <table><!-- very large table --></table>
      </div>
    </div>
  </div>

However, there is an issue when the table becomes too tall for the current page. The bottom scroll bar of the scrolling div disappears off-screen, as the main vertical scrollbar takes over. To resolve this problem, I attempted:

<div style="overflow: auto; position: absolute; top:0;right:0;bottom:0;left:0;">

Unfortunately, this caused the div to extend across the entire page, overlapping with the sidebar. What would be the best approach to fixing this display problem?

Answer №1

To ensure the div is only as wide as your sidebar (200px from the left with a 20px padding, totaling 220px), make the following adjustment in your code:

<div style="overflow: auto; position: absolute; top:0;right:0;bottom:0;left:220px;">  

To address the bottom scrollbar issue, consider setting a specific "width:" for your table element like this:

table {
    width: 700px;
}

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

What is the best way to vertically flip a background image that is repeating along the y axis in CSS?

I am in the process of developing a mobile web app and I need assistance with flipping the background image when it repeats along the y-axis. Can someone guide me on how to achieve this using CSS or JavaScript? https://i.stack.imgur.com/b107V.jpg var el ...

Show a modal with Jquery

Upon page load, I want to display a popup message. The popup is appearing correctly, but the close button in the bar is too big and doesn't fit properly. How can I adjust the size of the bar to accommodate the button? <script src="https://code.j ...

Unable to extract certain features from Zillow's website

My current project involves extracting data from the Zillow website. For example, check out this link: I've encountered an issue while attempting to scrape the price and tax history sections. It seems that these elements are loaded using JavaScript ...

How to horizontally center a div between two floated elements

Check out this JSFiddle example. I'm facing a challenge in horizontally centering the div class="filter-group" between two floated buttons within the given example. I've tried various methods but haven't been successful so far. Any assistan ...

Setting the Page Title in AngularJS 1.4.4: A Quick Guide

I'm faced with the code below <!doctype html> <html lang="en" data-ng-app="AlexsApp"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>{{$scop ...

The Vertical Spacing Between Dividers and Proper Size of Sub-Dividers to Accommodate Content on the Page

First and foremost, a huge thank you to everyone who has assisted me in resolving numerous issues related to my basic layout and syntax. I believe I have successfully cleaned up my syntax, and my CSS and HTML development are progressing smoothly. Now, let ...

JavaScript - Add dropdown menus from choices

Is there a way to automatically generate multiple select lists from a select list, similar to this example: https://i.sstatic.net/D33Jg.png Here is the code I have tried: HTML: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.m ...

Searchable dropdown -

Can someone please help me with an issue I am facing? When I try to focus and select from the up and down arrow keys, it is not working as expected. Below is a snippet of my code: <!DOCTYPE html> <html lang="en"> <head> < ...

Select a random class from an array of classes in JavaScript

I have a collection of Classes: possibleEnemies: [ Slime, (currently only one available) ], I am trying to randomly pick one of them and assign it to a variable like this (all classes are derived from the Enemy class): this.enemy = new this.possibleEn ...

Logged-in users experiencing issues with their bookings not showing up

It's me again! I am still struggling to display user bookings when the user is logged in. I feel like I might be missing something really basic here, but I just can't figure it out. Below is the code I've been working on. Any fresh eyes or ...

Tips for permitting the "checking" of just a single checkbox

Is it possible to customize this codepen so that only one item can be checked at a time, with the ability to automatically uncheck the previous item when a new one is checked? Also, is there a way to use a custom image for the check mark instead of the d ...

Place the video element within the Canvas element

I'm trying to incorporate a video player on Canvas. My video has an alpha channel, and I want to play it over a jpg image. This is the code snippet I've put together: <video id="mainVideo" src="item0.mp4"> </video> <canvas id="m ...

What is the method for retrieving the font size of elements in the native view using appium?

Can the font size of text in the native view be retrieved using appium? I am aware of using driver.findElement(By.id("by-id")).getCssValue("font-size"); for web views. Is there a similar method for native views? ...

Styling grids in Xamarin

My current project involves using CSS styles with Xamarin Forms. I have a grid with buttons that look like this: https://i.sstatic.net/awLWc.png StackLayout { background-color: #1e1e1e; color: #ffffff; } Button{ background-color: #2d2d30; ...

Experiencing problems with the calling convention in JavaScript

Here is a snapshot of the code provided: If the function testFields at Line:3 returns false, then the program correctly moves to Line:21 and returns the value as false. However, if testFields returns true, the program proceeds to Line:4, but instead of ex ...

Creating a user-friendly navigation menu: A step-by-step guide

I need help creating a navigation menu for my website that isn't functioning properly. Here is the code I am currently using: body{ margin: 0px; padding: 0px; } nav > ul{ margin: 0px; padding: 0px; } nav > ul > li{ fl ...

Identifying flags that do not actually exist in flag-icon-css library

Please take a moment to review the code snippet provided. I have created a Datatable that contains countries along with their country codes. Within my code, I am generating HTML to display flag icons using the format flag-icon-COUNTRYCODE. However, some ...

Does anyone know the ins and outs of how the website www.nikebetterworld.com was created?

Hello, I am new to web development and I am interested in creating a page similar to the style of nikebetterworld. Can you point me in the right direction on where to start studying to achieve this design? My impression is that it involves multiple scrol ...

The grid elements are not in perfect alignment

I'm having trouble aligning the <p> element to the left and the image to the right. The image is not aligning properly with the fourth column, so I need to figure out how to fix that. .content{ display: grid; grid-template-columns: 25% 25 ...

Displaying XML HTML Code in an Android Webview

Is it silly to want to display HTML Code in an Android Web-View? How can I achieve this? I have tried a few methods without much luck: Using loadDataWithBaseURL with mymetype="text" Inserting a textarea into my webpage and displaying the HTML there. ...