the scrollbars are appearing on the window instead of within my div container

I'm having trouble getting a scrollbar on my div element when the content is too wide. Instead, the scrollbar always appears on the window itself. I have tried adjusting the overflow settings but can't seem to find the right solution.

jsFiddle

HTML

<table class="wrapper" cellSpacing="0" cellPadding="0">
    <tr>
        <td class="header">
            <div>
                <p class="title">HEADER</p>
                <p class="subtitle">subheader</p>
            </div>
        </td>
    </tr>
    <tr>
        <td class="content">
            <div class="clearfix">
                <div class="col4">
                    <div>
                        <label class="fieldname">Field 1</label>
                        <span class="fieldcontrol"><input type="text" id="Text1" /></span>
                    </div>
                    <div>
                        <label class="fieldname">Field 2</label>
                        <span class="fieldcontrol"><input type="text" id="Text2" /></span>
                    </div>
                    <div>
                        <label class="fieldname">Field 3</label>
                        <span class="fieldcontrol"><input type="text" id="Text3" /></span>
                    </div>
                    <div>
                        <label class="fieldname">Field 4</label>
                        <span class="fieldcontrol"><input type="text" id="Text4" /></span>
                    </div>
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td class="footer">
            <div class="clearfix">
                <div class="left">
                </div>
                <div class="right">
                    <button type="submit">Ok</button>
                    <button>Cancel</button>
                </div>
            </div>
        </td>
    </tr>
</table>

CSS

.content > div
{
    overflow: auto;
}

This setup includes a header, body, and footer using a table structure. In the body section, I want a div element to expand to the full width and height of the table cell. When I resize the window, I expect the header and footer to resize accordingly while the body displays a scrollbar if the content overflows.

Thank you!

Answer №1

Wouldn't it be more efficient to use only div elements for this layout? http://jsfiddle.net/tP79v/2/

Here is the HTML code:

<div class="header">Header</div>
<div class="main">
    <div class="toBig"></div>
</div>
<div class="footer"></div>

And here is the CSS code:

.body {
    overflow:hidden;
}

.header {
    position: absolute;
    top:0;
    left:0;
    width:100%;
    height:30px;
    background-color:lightblue;
}

.main {
    position: absolute;
    top:30px;
    bottom: 20px;
    width:100%;
    left: 0;
    background-color:red;
    overflow: auto;
}

.toBig {
    position:relative;
    width: 1000px;
    height: 200px;
    background-color:yellow;
    margin:20px;
}

.footer {
    position: absolute;
    bottom:0;
    left:0;
    height:20px;
    width:100%;
    background-color:green;
}

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

Hover Effect for Bootstrap Gallery

I've created a hover effect for my gallery that is embedded in a Bootstrap Grid. Although the hover effect itself works fine, on some screen sizes, the overlay ends up covering the gallery images. Does anyone have any ideas, solutions, or hints to so ...

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 ...

Javascript - When I preview my file, it automatically deletes the input file

My form initially looked like this : <form action="assets/php/test.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> ...

Adjust the spacing between the title and other elements in an R Shiny application

How do I modify the font and size of a title, as well as add some spacing between the title and other elements? navbar <- navbarPage( Title = "Intervals", tabPanel("Data Import", sidebarLayout(sidebarPanel(fi ...

Using jQuery to send a post request to a PHP script using either JavaScript or PHP

Just a quick question for those with experience. I am working on a page where I have implemented a jQuery AJAX post to another PHP page that contains JavaScript. My concern is, will the JavaScript code also be executed? Another scenario to consider is if ...

Permitting various valid responses for questions in a multiple-choice test | Utilizing Angular.js and JSON

As a beginner in this realm, I must apologize if my query seems naive. I recently crafted a multiple-choice quiz using HTML, CSS, JavaScript (angular.js), and a JSON data file following a tutorial I stumbled upon. The outcome pleased me, but now I am face ...

Tips on applying the "activate" class to a Bootstrap navbar in Angular 2 when implementing page anchor navigation

As I work on my single-page website using Angular 2 and Bootstrap 4, I have successfully implemented a fixed navbar component that remains at the top of the page. Utilizing anchor navigation (#id), the navbar allows smooth scrolling to different sections o ...

Levitating with Cascading Style Sheets

Looking for some assistance to troubleshoot my code. I am trying to make the hover color apply only to the navigation bar and not affect the pictures. I attempted to solve this by specifying .a.main-nav:hover { ...}, but it ended up removing the hover effe ...

Reduce the size of the header in the Sydney theme for WordPress as you scroll

Currently, I am attempting to reduce the size of the header once scrolling down. My focus is on refining the child theme. Displayed below is a screenshot illustrating the appearance of the header at the top of the page: https://i.stack.imgur.com/wojGf.pn ...

What is causing this iframe ads code to so severely disrupt the functionality of Internet Explorer when using document.write

So, I've recently encountered an issue where a certain problem arose, and although I managed to fix it, I am still curious about the root cause behind why it occurred in the first place. TL;DR The use of Google-provided conversion tracking code that ...

Canvas - Drawing restricted to new tiles when hovered over, not the entire canvas

Imagine having a canvas divided into a 15x10 32-pixel checkerboard grid. This setup looks like: var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); var tileSize = 32; var xCoord var yCoord ...

DataTables.js, the powerful JavaScript library for creating interactive tables, and its compatible counterpart

I'm currently making some changes to a dynamic table that require enabling a vertical scroll bar. As a result, I need to implement this vertical scroll bar mechanism on an existing table. The code in our project utilizes dataTables.js version 1.5.2 ...

Leveraging the power of React in conjunction with an HTML template

After purchasing an HTML template from theme forest, I am now looking to incorporate React into it. While I find implementing Angular easy, I would like to expand my skills and learn how to use React with this template. Can anyone provide guidance on how ...

The appearance of my website appears differently depending on the resolution

Just recently, I began exploring the world of HTML/CSS/JS and created a handy tool for my personal use. However, I encountered an issue when viewing it on different resolutions which caused some elements to look distorted. The tool I made allows me to inp ...

What is causing the issue where Multiple file selection does not work when using the multiple attribute

I am having issues with uploading multiple files on my website. I have created an input field with the attribute multiple, but for some reason, I am unable to select multiple files at once. app.html <input type="file" (change)="onChange($event)" req ...

Ways to speed up the disappearance of error messages

There is a minor issue that I find quite annoying. The validation error message takes too long (approximately 3 seconds) to disappear after a valid input has been entered. Let me give you an example. Do you have any tips or tricks to resolve this problem? ...

The inner HTML functionality in Angular 2 seems to be malfunctioning when dealing with HTML tags

I am facing an issue with an array that includes displayName with HTML tags: this.topicsList = [ {id: "173", name: "Discussion1", displayName: "Discussion1", status: 1}, {id: "174", name: "discussion123", displayName: "discussion123", status: 1}, {id: "19 ...

What is the best way to align an Icon in the navbar-toggler of Bootstrap 5?

When working with Angular and Bootstrap to develop a navigation bar, I encountered an issue with aligning a user icon in the navbar. The picture below shows the problem that arises when trying to center align the user icon among other links in the navbar. ...

Is it possible to retrieve text from an html document?

I need to scrape a web page that is full of text and save that text into a file. I am currently attempting to use BeautifulSoup, but I'm not sure if it has the capability I need. Here's the situation: The specific text I want to extract is locate ...

Is it possible to verify .0 with regular expressions?

In my project, I have a field that requires whole numbers only. To validate this, I used a regex validation /^\d{1,3}$/ which successfully validates whole number entry and rejects decimal points starting from .1. However, I encountered an issue where ...