The sudden disappearance of the vertical scrollbar in an absolutely positioned element

UPDATE : Added link to the example: http://jsfiddle.net/bfNzH/1/

This is how my HTML structure looks:


    <body>
    <div class="wrapper">
        <div class="left">left bar</div>
        <div class="right">
            <div class="topbar">topbar</div>
            <div class="header">header</div>
            <div class="content">
                <div>..some stuff</div>
                <table>
                    <thead>
                        <tr>
                            <th class="th1">Col1</th>
                            <th>Col2</th>
                            <th>Col3</th>
                            <th>Col4</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</body>

CSS

 
body {
height : 100%;
}
.wrapper {
position : absolute;
top : 0;
bottom : 0;
left : 0;
right : 0;
overflow : hidden;
}
.left {
height : 100%;
position : absolute;
width : 50px;
overflow : hidden;
border-right : 1px solid black;
}
.right {
position : absolute;
top : 0;
left : 50px;
bottom : 0;
right : 0;
//border : 1px solid red;
}
.topbar {
height : 20px;
display : table;
width : 100%;
border-bottom : 1px solid green;
}
.header {
height : 30px;
display : table;
width : 100%;
}
.content {
width : 100%;
height : 100%;
position : absolute;
overflow : auto;
top : 50px;
bottom : 0px;
border-top : 1px solid yellow;
border-bottom : 1px solid yellow;
}
.th1 {
width : 50%;
}
table {
width : 100%;
}
th, tr {
text-align : center;
}

In case my table has numerous rows, the content extends beyond the page and a scrollbar appears. However, the scrollbar placement isn't ideal:

I realize that due to the absolute positioning of elements and adding a top, the vertical scrollbar is offset by that much.

I am looking for one of these solutions:

  1. Adjust the scrollbar position on the content element
  2. Move the scrollbar to the table body

The second solution can be achieved by applying display : block to tbody, but it disrupts the alignment significantly. Please see the issue below:

Answer №1

By eliminating the height: 100%; attribute from the content block, the true height of the scrollbar becomes visible:

http://jsfiddle.net/bfNzH/4/

Answer №2

Make sure to review the "Overflow" property in your Content section, as it could be set to hidden with a particular height assigned to it.

Answer №3

Eliminate the CSS style: "height:100%" from the element with class ".content".

I recommend utilizing a browser debugger tool to troubleshoot any issues you may encounter. Firebug is a great option for Mozilla, while Chrome offers its own built-in debugger tool. Wishing you success in resolving your problem more efficiently next time.

Best regards.

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

The WordPress GD Star rating plugin is failing to load on the webpage

I am having trouble getting the GD star rating plugin to load on my website. I followed the correct installation and configuration steps, but the plugin still won't show up on the page. I have attempted various solutions without success. Can anyone s ...

Screen proportions altered - Background image disappearing | Unusual occurrences |

If you look at my site everything seems to be ok, ... untill you minimize the website. A horizontal scrollbar appears and when you use that scrollbar, you will see that my image has vanished. My Website I made that image responsive...so i have no idea wh ...

How to extract the date value from an HTML date tag without using a datepicker

Utilizing Intel's app framework means there is no .datepicker method available. The following code snippet generates the date widget within my app: <label for="startdate">Start Date:</label> <input type="date" name="startdate" id="star ...

Setting the title attribute for option elements in a select element that is bound to a model using AngularJs

I'm currently working on an HTML select element that is connected to an ng-model. Here's what the setup looks like: <select data-ng-model="accountType" data-ng-options="at.name for at in accountTypes"></select> This is how my accou ...

Tips for enhancing your HTML email template with borders:

I designed an email template using the email template editor and incorporated nested table tags for each mail element. As I created a table to contain all these elements and attempted to add borders to the tags, I encountered a space between the top and bo ...

Positioning a div with text over an image in a way that it

Hey everyone, I've run into a bit of an issue with my project. I'm trying to create a system where text appears over an image, but the problem is that my div is set to absolute position and I can't switch it to relative without causing major ...

Having trouble locating the search bar element on Walmart's website?

I'm currently working on a bot that needs Selenium to interact with the search bar on Walmart's website, where it will input the name of a specific product and perform a search. However, I've encountered an issue where no matter what method ...

Is there a way to obtain a user's screen size without relying on a physical device or measuring the diagonal?

I'm looking for a way to display something at its actual size on a browser. For instance, if something appears to be 20cm on the screen, I want it to truly measure up to 20cm. Some methods involve considering the diagonal resolution of the screen, li ...

What is the best way to smoothly reveal images one by one?

My goal is to smoothly slide three images inside a div, one by one. However, I'm facing an issue where the images stack on top of each other and end up stuck in their original positions. Here is the code snippet I've been working with: <div ...

Using JavaScript to adjust the width of the table header

I have a table that I need to adjust the width of using JavaScript or jQuery. <div class="dataTables_scrollHeadInner" > <table class="table table-condensed table-bordered table-striped dataTable no-footer" > <thead ...

Searching for a div table using XPATH in Python

Struggling to extract data from a table using Selenium in Python. Any suggestions on how to achieve this? https://i.stack.imgur.com/rPlKR.png <div class="js--property-table-body project-property-table__body"> <span aria-hidden=&quo ...

What is the alternative method for submitting a value in a <select><option> without using a submit button?

Below is the code snippet I am working with: <form action="?sort=SELECTEDVALUEHERE" method="GET> <select> <option value="1">Option 1 </option> <option value="2">Option 2 </option> <option value="3">Option 3 < ...

Event handlers for textboxes in Visual Web Developer are a crucial component for

Having some difficulty with textboxes - ideally, I would like my second textbox to clear whenever the text in my first textbox changes. Currently, it only clears on postback but is there a way to achieve this without needing a postback for each character ...

Retrieve information from specific dates by using a datepicker tool

Hey there, I'm trying to implement a datepicker calendar that allows me to select two dates and then click a button to display all the data between those dates. Here is my code snippet... <?php include_once 'header.php'; $con = mysqli_ ...

Exploring ways to loop through a JSON array and embed it into an HTML element

After the ajax request, the data returned is structured as follows: Data = [ ["18/02/2019", "A"], ["19/03/2019", "B"], ["21/05/2019", "C"], ] The ajax request was successful and the data is stored in a variable named Data within a function. ...

I'm struggling to activate the eventListener on several elements with the same className or ID. Unfortunately, only the initial child is being triggered in my current code implementation

Hello fellow developers, I'm facing an issue while working on a project. I have about ten menu items with the same ID, and I want to be able to edit each one when it is clicked. Here's what I tried using JavaScript: const menuElement = d ...

Bootstrap column spacing explained

This code was created following the official bootstrap tutorial -> See Screenshot Implemented using the code below -> <div class="card-deck mb-3 text-center"> <div class="card mb-4 shadow-sm"> <div class="c ...

Forwarding to another servlet based on the action of an HTML page

There are 2 servlets included in my code snippet @WebServlet("/Login") public class Login extends HttpServlet { ......... ......... } @WebServlet("/Create") public class Create extends HttpServlet { ......... ......... } Accompanied by an HTML page ...

Connecting ViewChild to several elements

I have implemented a feature where I am displaying tabular data in DataTable for Angular. Within this, there is a button that triggers a click event. Upon clicking the button, a slide menu is displayed, which then triggers a modal open. To achieve this fun ...

What is a tag in CSS that is agnostic to layout?

Is there a secret tag in HTML (4) that I can utilize for CSS differentiations? tag.myclass tag.mysubclass h1 { } without causing any visible changes to the rendered HTML? I have sections in a form that are part of different categories. When opening the ...