Creating a fully responsive Bootstrap column with 100% height

I am currently working on a page that features the following HTML structure:

<html>
    <head>...</head>
    <body>
        <div class="container">
            <header>...</header>

            <div class="wrapper">
                 <div class="row">
                     <div class="col-md-8">...</div>
                     <div class="col-md-3 col-md-offset-1 col-aside">
                         <aside>...</aside>
                     </div>
                 </div>
             </div>
        </div>
    </body>
 </html>

I have set the height to 100% for the following elements:

html, body, body > .container {
    height: 100%;
}

.wrapper {
    min-height: 100%;
}

.wrapper > .row {
    min-height: 100%;
}

.col-aside {
    min-height: 100%;
}

However, when inspecting the page with Chrome Developer Tools, I noticed that .row and .col-aside are not achieving the desired 100% height. Despite seeing solutions involving display: table, I would prefer to avoid this method since I was able to create the layout using simple divs without Bootstrap. Can anyone provide guidance on how to ensure both columns have a minimum height of 100% without relying on display: table or position: absolute?

Update: Check out this jsfiddle link for reference: http://jsfiddle.net/U6H6W/. Here you can observe that while the .wrapper achieves 100% height, the .row does not.

Answer №1

An effective solution is to utilize viewport height, like so:

.sidebar {
     height: 100vh;
}

By using this method, you can set the height of a specific div without the need to define the heights of parent HTML elements.

Viewport height is compatible with all major browsers, including IE9 and newer versions. For legacy support back to IE8, you can implement a fallback option by setting height: 100% (ensuring it covers all containing blocks).

For a practical demonstration, check out this jsbin:

http://jsbin.com/yakazufi/2/edit

Answer №2

When working with the CSS property height:100%, it is important that all parent elements also have a height:100% set. If any parent element does not have this, then the child elements will not behave correctly.

The 100% height approach can be tricky, especially when dealing with multiple child elements that have padding or margins. This may result in unexpected display issues such as exceeding the screen size.

One alternative to consider is using position: fixed with bottom:0, but keep in mind that you will need to manage the position of non-fixed divs accordingly.

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

Looking to incorporate nested rules in `JSS` using `CSS`?

Can someone guide me on how to use CSS class-nesting in Material-UI or JSS in general? I have been attempting the following: card: { cardHeader:{ marginTop:"30px" } } ...

Position the li elements within the ul at the bottom

I am trying to align a li element at the bottom of a ul list. +------+ | li1 | | li2 | | li3 | | | | | | | | li4 | +------+ Any suggestions on how to achieve this? MY ATTEMPTED SOLUTION: li4 { position: fixed; bottom: 0; } W ...

Having trouble sending the contact form

I had everything working perfectly for a brief moment, but now I can't seem to figure out what went wrong. Although the form still redirects me to the intended page upon submission, my email remains oddly quiet. HTML <form id="contact_form" actio ...

Flashing background colors on a website

Can anyone explain why this code won't alternate the background color of my website between two different colors? <script type="text/javascript"> function blinkit() { intrvl = 0; for (nTimes = 0; nTimes < 3; nTimes++) { intrv ...

Placing an iframe at the end of a container

I am attempting to use jQuery to insert an iframe into a div. The current code accomplishes this, but it also erases all existing content within the div#off. How can I make the iframe appear at the bottom of the content in the div#off without removing any ...

Achieving Dynamic Center Alignment for One or Two DIVs

My goal is to create a page layout with three DIVS arranged as Left|Center|Right, while still being able to display different combinations such as Center, Left|Center, or Center|Right in the center of a wrapper div. I have been using jQuery toggle to swit ...

Modification of webpage content when URL hash changes

I am experiencing an issue with my script. Whenever I type something with a spacebar, like google map, it automatically changes in the input box to google+map, which is not ideal. Additionally, when I try to submit again, it further complicates the situati ...

Is it achievable to craft a Twitter Bootstrap 'nav-tabs' menu without altering the URL?

I am looking for a way to implement nav-tab functionality without the URL changing, while still being able to display different tabs with relevant information. My website is built using angularjs, and whenever the page refreshes, it redirects the user bac ...

Why are my styles not working when referenced from the .module.scss file?

Here is the code snippet from my Sublayout.module.scss file: .pl-6 { padding-left: 6rem !important; } .pr-6 { padding-right: 6rem !important; } .pl-12 { padding-left: 12rem !important; } .pr-12 { padding-right: 12rem !important; } After im ...

Using jQuery to generate several div elements inside one main div

Given the parent div structure: <div class="large-9 columns"></div> I intend to add multiple child divs inside the parent: <div class="large-9 columns"> <div>JSON data point 1</div> <div>JSON data point 2</ ...

Is itemprop="image" used on an element that is not an <img> tag?

My current product page utilizes Microdata where the itemprop="image" attribute is assigned to the first thumbnail in the gallery. I want to change it to specify the high-resolution image instead. The problem is, the high-res image is not directly display ...

Learn the trick to make this floating icon descend gracefully and stick around!

I'm trying to create a scrolling effect for icons on my website where they stay fixed after scrolling down a certain number of pixels. I've managed to make the header fixed after scrolling, but I'm unsure how to achieve this specific effect. ...

Limit Range of jQuery UI Slider Button

How can I modify the jQuery UI slider range to keep the button within the slider div and prevent it from overlapping as shown in the screenshots below? https://i.sstatic.net/odG3o.png https://i.sstatic.net/aiGxr.png ...

Overflowing is caused by excessive padding within the text field container

When trying to apply padding to a text field, I am facing an issue where the right side overlaps with the main content. How can I resolve this? <div class='container_section'> <input type='text' placeholder='name' ...

I'm having trouble with my tablet view taking priority over my desktop view - what could be causing this issue?

Styling for different screen sizes: @media (min-width: 991px) and (max-width:768px){} .container, .container1, .container2 .container3{ float: left; } .container1{ width: 50%; } .container2{ width: 50%; } .container3{ width: 100%; } /**** ...

Conceal the image within the second and third div elements using jQuery

I am facing an issue with my div structure <div class="block_content"> <img src="image1.png"> </div> <div class="block_content"> <img src="image2.png"> </div> <div class="block_content"> <img src="i ...

Can CSS3 be utilized to craft this specific shape?

Can CSS3 be used to create the shape I need? I came across this website http://css-tricks.com/examples/ShapesOfCSS/, but I am unsure if any of the shapes on that page can be customized to match the specific shape I have in mind. Thank you! ...

What is the return type of file_get_content() function?

This code is a simple attempt to retrieve the content of a file and store it in a local browser database using HTML5. Below is the code snippet: <!DOCTYPE HTML> <html> <head> <script type="text/javascript"> var db = openDatabase(& ...

Tips for repairing a side bar and header with CSS when using a JS & jQuery scroller

I am working on a layout design and my goal is to have the left sidebar, right sidebar, and header remain fixed in place. Here is the CSS code I am using : #container { padding-left: 200px; /* Left Sidebar fullwidth */ padding-ri ...

What is the best way to align these Iframes in the center?

This is the html <div class="main_content"> <section class="episodio"> <article class="contenedor_episodios"> <h2>Episodios</h2> <div class="episodio_spotify" ...