The div element on the HTML page is not displaying all of its content

I've created the following code snippet on JSFiddle. https://jsfiddle.net/msridhar/1zvhmpjq/11/ HTML file:

 <body>
<div id="headerDiv">
        <img id="headerImg" src="" width="280" height="125" alt="DummyLogo"/>
        <pre id="headerPre">
                 Test Series
        Cloud Solutions
        </pre>                  
        <hr id="headerHR">
    </div>                              
        <div id="results">
        </div>      
</body>

CSS:

    html, body { 
        margin: 0;
        padding: 0; 
        height: 100%;                       
  overflow: hidden;
  }
  body{
    position: relative;
  }
      #results{         
  width: 100%;          
  height: 100%;
        position: absolute;
        top: 150px; 
        left: 300px;    
        overflow: auto;
      }
      body{
        position: relative;
      }               
        #headerDiv{     
            position: fixed;
            top: 0;
            width: 100vw;               
            //border-bottom: 3px solid #808080;
        }
        #headerHR{                                              
            width: 100%;
            height: 1px;
        }
        #headerImg{
            float: left;
            margin-top: 0px;
            margin-left: 0px;
        }
        #headerPre{
            float: left;
            font-family: "Arial", Helvetica, sans-serif;
            font-style: normal;
            font-weight: bold;
            font-size: 24px;
        }                   

Javascript:

$('#results').load('https://fiddle.jshell.net/ds2vxqbg/1/show')

The HTML file loaded through Javascript is as follows:

<table border="1">
      <tr>
        <th>Product no.</th>
        <th>Product name</th>
        <th>Product type</th>
        <th>Product Description</th>
      </tr>
      <tr>
        <td>1</td>
        <td>Apple</td>
        <td>Fruit</td>
        <td>Its a fruit</td>
      </tr>
      <tr>
        <td>2</td>
        <td>Orange</td>
        <td>Fruit</td>
        <td>Its a fruit</td>
      </tr>
      <tr>
        <td>3</td>
        <td>Pineapple</td>
        <td>Fruit</td>
        <td>Its a fruit</td>
      </tr>
      <tr>
        <td>4</td>
        <td>Pear</td>
        <td>Fruit</td>
        <td>Its a fruit</td>
      </tr>
      <tr>
        <td>5</td>
        <td>Plum</td>
        <td>Fruit</td>
        <td>Its a fruit</td>
      </tr>
    </table>
    <img src="" width = "800" height = "600">
    <img src="" width = "800" height = "600">
    <img src="" width = "800" height = "600">
    <img src="" width = "800" height = "600">

I've inserted an HTML page into a div tag with the ID results. Even though the div has overflow-auto enabled, it's not displaying the entire content when scrolled. Can someone please help me identify the issue?

Answer №1

#results stops displaying properly when body {overflow:hidden;} is set because the div's width and height are constrained to 100% of the body, but there is an additional offset causing issues.

To resolve this issue, consider the following adjustments:

Update your HTML code:

<body>
    <div id="headerDiv">
        <img id="headerImg" src="" width="280" height="125" alt="DummyLogo"/>
        <pre id="headerPre">
             Test Series
            Cloud Solutions
        </pre>                  
    <hr id="headerHR">
    </div>
    <div id="wrapper">  <!-- add wrapper -->
        <div id="results"></div>
    </div>
</body>

Make changes to your CSS code:

#wrapper {
    padding-top: 150px;
    padding-left: 300px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

#results {
    width: 100%;
    height: 100%;
    overflow: auto;
}

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

Customize request / retrieve document cookies

I have successfully implemented a cookie in my express/node.js application. var express = require('express'); var cookieParser = require('cookie-parser') var app = express(); app.use(cookieParser()) app.use(function (req, res, next) ...

What are the steps to incorporate metrics middleware for Socket IO notifications, specifically monitoring both emitted events and listener activity?

I am currently working on a project that involves tracking all socket.io notification transactions initiated by the server, resembling an API request/response counter to validate subscription validation. Our team is utilizing an express middleware to moni ...

Using jQuery to retrieve the location of an element with a specific class

I am working on a slider that adds a class (.current-item) to each active tab and removes it when it's inactive. I am looking to incorporate the LavaLamp effect for the menu, but I am having trouble getting the position of each element with the curren ...

Adjusting the placement of a dropdown menu while scrolling within the container element using CSS

Is there a way to keep the submenu aligned under the button even when scrolling within the container div? Currently, it stays in the middle of the page. div.container { height: 200px; width: 400px; border: 1px solid black; overflow-y: scroll; ...

Unable to adjust column width and margin in fixed layout mode

I am having trouble setting the column width for a specific column in my table. The table has a layout=fixed and width=100%. I tried setting max-width=300px for one of the columns, but it seems like all columns are evenly distributed within the table. Unfo ...

Managing state in React hooks: Updating nested object state using useState()

In my application, there is a component that is passed a prop in the following structure: const styles = { font: { size: { value: '22', unit: 'px' }, weight: 'bold', ...

Value of MySQL in a web form

Currently in my PHP code, I have the following: echo '<input type="email" name="email" value=''; I am looking to automatically populate the value with a data from a MySQL row (let's say ['name']), but I am encountering syn ...

Enhance your website's animations using CSS3

Is there a possibility that jQuery will utilize the enhanced performance capabilities of CSS3 animations for functions like .animate(), .slideDown(), .fadeIn(), and others in the future? Seeing this integration would be greatly appreciated, either through ...

I encountered a ReferenceError stating that the variable "req" is not defined when I try to

I am currently developing a login application using React.js and Node.js (Express, JWT), but I am facing an issue when trying to export my function. I keep receiving the error ReferenceError: req is not defined, even though I have defined req. How can I re ...

What is the best way to assign a numeric variable to the value attribute of an HTML form input?

Is there a way to assign a numeric value to the value attribute of an HTML form input element using a variable? I understand that the value attribute automatically gets converted to a string. How can I make sure the variable is read before being converted? ...

Is it not possible to import in SCSS if the variable is equal to the value?

In my project, I am utilizing scss. There is a variable that determines which scss file needs to be imported based on its value. I attempted the following approach: $test: 1; @if $test == 1 { @import "./theme1.scss"; } However, an error message is dis ...

Eliminate an item from an array

How can you effectively remove the property "itemType" from the object provided below? { "id": 19, "cost": 10, "items": 10, "numbers": 10, "status": false, "hours": 10, "itemType": { "id": 16, "name": "PC 350", ...

Aligning images in center of list

I'm in need of some CSS expertise to assist with this layout. Here is the current structure: <div class="movieList"> <div class="image" selected = true> <img class="poster" src="image1" selected = true/> </div> <d ...

tips for rotating a bootstrap background image

I would like to know if it is possible to flip the background image of a section that contains both a navbar and a row in Bootstrap 5. I am aware of using <<transform: scaleX(-1)>> but this flips all the container elements. Is there a way to ac ...

I'm having trouble getting the "flex direction: row" property to work within a table row

First, I applied flex to the table > tr. Next, I configured the flex-direction to be row. table { width: 100%; } tr { display: flex; flex-direction: row; flex-wrap: wrap; overflow: hidden; width:100%; } td:nth-child(1) { flex: 0 0 20%; ...

Issue with verifying file existence utilizing $.ajax()

I'm currently facing a challenge checking for the existence of a file using $.ajax(). I am cycling through a JSON file with $.each and trying to determine if a specific staff member has an image. If not, I want to default to using the no_photo.jpg ima ...

Adding new options to a multi-select dropdown in Vue.js when fetching data using an

Greetings! I've been utilizing a modified wrapper to manage a multiple select for vue.js. My goal is to change the value of 'this' inside the vue component. Below is the snippet of my code. <select2-multiple :options="car_options" v-mode ...

Tips on properly styling HTML using the BEM naming convention

I'm trying to implement BEM naming in my project, but I'm having trouble with how to name elements within elements. BEM guidelines state that elements of elements should not exist. How should I approach naming them correctly? <div class="cont ...

State of an array has been modified

After toggling the state of a checkbox from true to false, calling setState does not immediately reflect the update on the screen. Instead, another element with state must be interacted with in order to trigger a refresh and display the new value of the ch ...

Send documents via a form by utilizing the text input function

At the moment, I am currently utilizing type="file" for file uploads. However, my specific scenario requires me to upload directly from a text box with the complete file path provided. <form action="upload_file.php" method="post" enctype="multipart/for ...