Creating an overlapping HTML/CSS div within a parent div

After successfully building numerous websites and fixing various issues along the way, I now find myself stuck on a particular problem. Despite my experience, I can't seem to figure it out this time.

The issue lies within a wrapper div that contains two inner divs. When the content in the inner div exceeds the height of the wrapper div, it simply overlaps instead of expanding the wrapper div's height. My objective is to make sure the wrapper div adjusts its height according to the inner div.

Here is the code snippet I am currently using:

<body>
    <div id="wrapper">
        <div id="site-wrapper">
            <div id="header"></div>
            <div id="colpos">
                <div id="columnLeft">
                    <div id="mainWrap">
                        <div id="contentBar"></div>
                        <div id="main">
                            Content 
                            <div id="longDiv">Very long</div>
                        </div>
                    </div>
                </div>
                <div id="columnRight">
                    <div id="links">
                        <div id="navBar"></div>
                        Links
                    </div>
                </div>              
            </div>
            <div id="footer">Copyright</div>
        </div>
    </div>
</body>

And here is the corresponding CSS style:


html {
    margin: 0px;
    padding: 0px;
    font-family: Calibri, arial;
}

#longDiv{
    height: 2000px;
    color: white;
    background-color: black;
}

#wrapper{
    width: 1200px;
    margin: 0px;
    padding: 0px;
    border: 0px;
}
/* Additional CSS styles removed for brevity */

In summary, my current setup has resulted in an overlapping issue as shown in the image here. Your help in identifying the mistake I've made would be greatly appreciated. Thank you in advance.

Sincerely, EvilTuinhekjeNL

Answer №1

When you set the wrapper's height to 100%, it restricts its size to the height of the browser window. However, a long div within this wrapper will exceed this height limitation.

To resolve this issue, eliminate the 100% height from the wrapper and other containers. If you want the content to be limited to the viewable document area, consider using position: absolute on your divs and setting their top, left, right, and bottom values to match the screen boundaries.

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

How can I align a mapped button to appear on the opposite side of the data using Tailwind CSS?

I've been struggling to find a straightforward solution to this issue for a while now. Let me break it down - I need to display some data on the left side of a post card component with a button located right next to it. Here's an illustration: ...

Transformation of HTML occurs in React components upon saving in Visual Studio Code

As I embarked on my journey to learn React, I hit a roadblock early on. Searching for a particular setting, I somehow ended up selecting something different, like NodeJS. Now, the issue at hand is: Behold the First Image: https://i.sstatic.net/ETmDk.png ...

Issue with displaying Git remote repository on list item element (ul) not appearing

My attempt to showcase my GitHub repositories via their API is not displaying on my webpage, even though the exact same code works perfectly fine here on JSFiddle Upon debugging, it seems that the script is being invoked but the content is not loading wit ...

Experience the feeling of releasing momentum by click and dragging the scroll

One feature I am looking for is the ability to control the scroll speed when dragging, and have the scroll continue moving slightly after release instead of stopping instantly. CodePen: https://codepen.io/rKaiser/pen/qGomdR I can adjust the speed adequat ...

Issue with Second Accordion Panel not refreshing

Within my accordion setup, the initial panel showcases a selection of icons. Upon choosing one of these icons, it triggers the display of one of three panels in place of the second accordion panel, based on the selected icon. The issue seems to be rooted i ...

Align the text on the same horizontal line

I have been struggling with this issue for hours. Here is my Header.js <div className="navbar-inner"> <h2>Text1</h2> <h3>Text2</h3> </div> This is the content of my Header.css: .navbar-inner { ...

Swapping out a Django template variable for a variable generated using JavaScript

I'm new to Django and Javascript (less than 3 weeks!) and I have a query that may seem naive, so any assistance would be appreciated. In my current code, I have an HTML table rendered with the following snippet: <table border="1" class="dataframe ...

Are there CSS styles that target specific elements?

My goal is to design a unique and custom theme for blender.stackexchange. However, I am facing an issue where the rules I implement only affect certain tags when viewed in FF 29.0.1 Despite all tag elements having the same classes, parent elements, etc., ...

Image stays the same in Ajax despite different dropdown choices

HTML <div class="new-product"> <div class="col-md-5 zoom-grid"> <div class="flexslider"> <ul class="slides"> <li data-thumb="images/<?php echo $productimg1?>"> ...

Why isn't a single click enough to activate an anchor generated with the Sidr jQuery library in Rails?

I am utilizing a library named Sidr to generate sidebars. I have included all the necessary jQuery and CSS, and while it is operational, I find that I need to double click instead of just one click to open the sidebar. Here is the code snippet. I essentia ...

Struggling with positioning of dropdowns on Bootstrap 4-alpha-2 navbar

The screenshot above showcases the responsive design functionality in Safari on OS X. The code snippet below demonstrates how the navbar is created, revealing that the dropdown menu on the right extends beyond the page. How can this issue be rectified? ...

Locate Item Using Two Tags Within a Division

My goal is to locate the current value, but it is constantly changing. The name attribute "customerNum" is unique. I believe I need to leverage both of these tags. Unfortunately, whenever I attempt to do so, I encounter an error. Is there a way to proper ...

My custom font is not compatible with the browser on my asp.net site

I'm having trouble embedding my own font in my .aspx file. Google Chrome and Firefox don't seem to support the font, while IE does. Can someone please provide guidance on how to successfully embed the font in an asp.net page? Below is my code: ...

Is there another alternative for the <v-app> tag in Vuetify that can be used as a replacement?

UPDATE Kudos to Gabriel Tortomano for the solution! I swapped out the root <div> tag with <v-app and tackled the css adjustments that came with <v-app>. It turned out to be easier than expected. Just reset the properties that are automatic ...

overflowing bootstrap cards are causing disruptions in row layouts and impacting the margins of surrounding elements

As a beginner in the world of programming, I'm reaching out for help with my first post. Please bear with any errors in my code or confusion in my terminology. Experimenting with bootstrap cards on a blog template, I am facing an issue where the heig ...

Ensure the child element is selected immediately following an h2 tag using HTML and CSS

Consider the following brief HTML snippet: <div ...> <h2 class="test">...</h2> <p>...</p> </div> Is it feasible to retrieve the child element (p in this case) after the h2? I have been contemplating poten ...

JS/Electron Insert items individually

Apologies if my explanation is unclear. I have a function (shown below) that parses a JSON file and creates a grid of 1550 items. How can I add them one by one instead of all at once? Loading all 1500 items together is taking too long. function addItem () ...

What is the best way to organize table rows into a single column when the window is resized?

I am working on a table that has three pictures in a row, with 100% width. I want the table to be responsive and stack the pictures into one column when the space is limited. The issue I am currently facing is that the elements of the table do not stack i ...

Angular reactive form CSS styling that necessitates the form to be both touched and invalid

Utilizing a reactive form for users to update their password. I aim to customize the input boxes to indicate any invalid submissions or errors. input.ng-invalid { border: 1px solid red; } An issue arises where the styling shows even before the user inte ...

What is the best way to loop through jsoup elements while skipping the initial two results?

Extracting desired data from the following HTML snippet: <div class='col5'> <strong><a href="/stellenangebote/107278-supporter-sap-crm?page=1&amp;query%5Bcity%5D=&amp;query%5Bradius%5D=100&amp;query%5Btext%5D=SOA+SAP" ...