The side column does not reach the full height

I'm currently working on a sidebar for my website and I'm attempting to make it fill the remaining height of the page after the elements above it. Unfortunately, I haven't been successful in figuring out how to achieve this. I am utilizing Bootstrap 4, but it seems like the issue lies within my CSS code which I will share below.

.sidebar {
    float: left;
    width: 300px;
    height: 100%;
    background-color: #212529;
}
.wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    margin-top: -50px;
    margin-bottom: -30px;
}

#sidebar h1, h2, h3, h4, h5, h6 {
    color: #fff;
}

#sidebar {
    width: 250px;
    height: 100%;
    z-index: 0;
    background: #212529;
    transition: all 0.3s
}

#sidebar ul li a {
    color: #c3c3c3;
    padding: 10px;
    font-size: 1.1em;
    display: block;
    text-decoration: none;
}
#sidebar ul li a:hover {
    color: #7386D5;
}

#sidebar ul li.active > a, a[aria-expanded="true"] {
    color: #fff;
    background: #6d7fcc;
}
ul ul a {
    font-size: 0.9em !important;
    padding-left: 30px !important;
    background: #6d7fcc;
}

The troubled site is actually live at:

You can view all other relevant code there, however, my main concern lies with the sidebar implementation.

Answer №1

This explains the reason behind this occurrence.

It is important to note that percentage values in CSS depend on the parent element. For example, if the parent has a height of 50px and a direct child has a height of 50%, then the child's height will be 25px because 50% of 50px is 25px.

However, if the parent has a height of 0 (which is the default value), then setting the child's height to 100% will result in a height of 0 because 100% of 0 is 0.

Flexbox does not set the height of the parent; it simply allows children to stretch to fill the available space.

In a flex environment, your wrapper's height is determined by its content. So when you specify height:100%, it follows the height of the content (in this case, the nav#sidebar and main elements).

If the main element has a greater height, the parent's height will equal the main element's height. Setting height:100% on a child element will make the parent's height act as if only that child exists. If you remove the main element altogether, then height:100% will work because, as mentioned earlier, flexbox stretches the children accordingly.

Answer №2

To resolve the issue, simply eliminate the 100% declaration from your .container. It seems that this caused the elements to exceed the boundaries of their parent container without considering height adjustments.

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

Formatting the numbers for an unordered list located outside of the content

Can the numbers of an ordered list be formatted using the list-position-style set to outside? I am looking for a solution using only CSS since I cannot edit the HTML. Essentially, I want styled numbers with round background to replace the outside numbers. ...

hyperlinks along the edges surrounding a centrally positioned image

I'm facing an issue with an image that is also a link. I used the following code: <a href="link.html"><img src="img.png" id="cloud"></img></a> After, I centered and resized it with the help of this CSS: #cloud { display: blo ...

Establish height and width parameters for creating a dynamic and adaptable bar chart with recharts

I am currently facing an issue with recharts while trying to implement a BarChart. The setting width={600} and height={300} is causing the Barchart to be fixed in size, rather than responsive. How can I make the BarChart responsive? I attempted using per ...

Eliminating white space - A CSS and HTML page with no room for gaps

After finally getting my website up and running using style.css, I am faced with the following CSS code: html { height:100%; } { position: relative; z-index: 0; width: 100%; left: 0; top: 0; cursor:default; overflow:visible; } body { ...

Troubleshooting compatibility issues between JS and ng-view in AngularJS

In my AngularJS SPA project, I am using ngRoute along with Bootstrap's Carousel template. However, I have run into an issue where certain functionalities ceased to work once I started using ng-view instead of placing all the main content in the index. ...

Show jQuery block and make it fade in

I'm attempting to put together a simple tab system where each tab is supposed to appear using a fadeIn effect. In the code below, the .field element is initially hidden with CSS. Although the tabs are displayed correctly, the desired fadeIn effect is ...

Mouse click failing to trigger CSS property update

I am attempting to create an accordion feature. I want the accordion to expand when hovering over the "accordion head," and also show/hide the accordion body when clicking on the "accordion head." I have successfully implemented the show/hide functionalit ...

Blank space on the lower portion of my website as I attempt to implement a responsive layout

Working on making my webpage responsive for iPad and mobile devices. While adjusting the media query, I noticed a white area at the bottom of the page that seems to be outside the body element. Unsure of where it's coming from. Any help would be great ...

How can I use absolute positioning and scrolling with an Iframe?

One of the key elements of this website is the implementation of iframes, with only one displayed at a time. However, my current issue revolves around the inability to scroll within these iframes due to their absolute positioning. I have attempted variou ...

Guide to ensuring uniform card height in Bootstrap 4

Struggling with creating cards of equal size. I have been trying different solutions like using h-xxx, align-items-stretch, and Height:100% but still unable to make my cards have the same size or height in this case. This is my current code: <div c ...

Are there any aesthetically pleasing CSS themes available for GWT integration?

This inquiry has been raised in the past... GWT 2.0 Themes? GWT Themes and Component Libraries ...however, two years have elapsed. Previously, the response was mainly negative unless utilizing a widget library. I am on the lookout for an appealing CSS ...

Ensure that the z-index of the div element is properly set

Here's the HTML code I'm working with: <div class="caption_center"> <h1 class="caption_header font-alpha">Making Your World More Comfortable</h1> <p class="caption_regular font-alpha">Let us convince you of that&l ...

The XPath function $x() will always return an array, regardless of whether or not an index is specified

How can I target the div elements that have the class "month-table_col" (selecting by month). ... <div class="month-table"> <div class="month-table_row"> <div class="month-table_col">Jan ...

Is the custom CSS being overridden by the bootstrap.css.map file?

I am currently working with Bootstrap 4 and I am attempting to adjust the padding for the navigation links within the navbar using my own custom CSS file: .nav-link { padding: 0.15rem; } However, the styling that is being applied comes from the followin ...

Trouble with CSS Styling in Implementation of Website on Heroku

While the deployment of the application on the server works perfectly, there seems to be an issue on the website itself. The content is displayed without the CSS styles. Original Website link: This problem is not present when accessing the application lo ...

Understanding the contrast between viewport and responsive web design is essential in developing a

Can you explain the distinction between using <meta name='viewport'> and implementing Responsive web design with CSS Media Screen? It appears that these two methods serve similar purposes. Even without including <meta name='viewpo ...

Content on the page is not fully visible on mobile devices when the Right-to-Left attribute is applied

I recently added multilanguage support to my blog using the RTL attribute. However, I noticed that when users switch to another language, the page content shifts from LTR to RTL. Everything was working fine until I encountered an issue with a toggle tab o ...

The color attribute enhances the appearance with a colored border specifically designed for Chrome users

Starting off, I appreciate the border that Chrome applies to my inputs. However, I am facing an issue with the textarea element. The problem is that the textarea uses the color attribute not only for coloring the text but also as the border color. Here is ...

The Bootstrap Library reference causes the anchor hover function to malfunction

Feeling frustrated after encountering an issue where the Bootstrap button class interferes with the hover function in standard CSS. Decided to create a custom solution by adding a grey box next to the button to display hover information instead of using t ...

When you hover over nested HTML-lists in a webpage, make the tree's long text lines expand gracefully using a combination of HTML, CSS

In my Angular 4 application, I have a left div that displays a tree of items as recursive HTML lists. When there is a long text, it gets cut off by the border of the div and a scrollbar appears. I want to have the text expand beyond the border and show in ...