The min-height property in Bootstrap 3 causes a div element to not expand as expected

Having a bootstrap 3 page with a centered box that contains content, I noticed that the box does not expand when the content grows. The bootstrap container grows, but the box remains static. I have tried using "position:relative" and "overflow:hidden", as well as "container-fluid", but none of these solutions worked.
I am puzzled as to why the box is not expanding.

Here are my CSS styles:

   html,
    body {
        height:100%;
        width:100%;
    }

    .container {
        height:100%;
        min-height:100%;
    }

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

.box {
    height:90%;
    min-height:90%;
    max-width:1100px;
    background-color:rgba(0,0,0,0.83);
    text-align:left;
    padding-left:5%;
    padding-right:5%;
    padding-top:1%;
    overflow:hidden;
    position: relative;
}

HTML:

<div class="container">
        <div class="row">
            <div class="box">
                <div class="col-xs-12">
                </div>
            </div>
        </div>
</div>

Answer №1

The height of your box is set in a hardcoded manner, which is why it isn't expanding as more content is added. To address this issue, you should adjust the height property to auto. Additionally, if you want the box to have a minimum height when there isn't much content present, you can include min-height: 100vh;

.box {
    height:auto;
    min-height: 100vh;
    /* etc.
}

Check out the functional Fiddle

Answer №2

When utilizing bootstrap, consider structuring your code in the following manner:

<div class="container">
    <div class="row">
        <div class="col-md-12 box">
            <div class="col-xs-12">
            </div>
        </div>
    </div>

To set the height, use the following CSS snippet:

.box
{ 
  height: 100%;
}

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

What is the best way to customize a component in a view?

<template> <div class="about"> <Header /> <h1>Welcome to the dashboard page</h1> </div> </template> <script> import Header from "../components/layout/Header.vue"; export default { name: "dashb ...

What's causing the appearance of a horizontal scrollbar?

I'm puzzled by the appearance of a horizontal scroll bar on my webpage and I can't seem to pinpoint the exact cause. I've tried simplifying the page as much as possible, but there still seems to be an issue. Here's all the information I ...

What is the best way to alter the font size in an SVG?

I have incorporated an SVG icon into my website and obtained the following code from Adobe Illustrator: <svg id="Livello_1" data-name="Livello 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448.05 436.7"><path d="M190.5,66.9l22.2-22.2a23.9, ...

Element that emulates a different element in HTML

Is it possible to have one element that can control and change multiple clone elements, mimicking every change made to the original? While JavaScript & jQuery can easily achieve this, most solutions involve separate variables or instances for each element ...

When using classList.replace, it should swap out every instance of the class xxx1yyy with xx

I attempted to swap a class and came across this helpful example here: javascript: replace classList that is inside a conditional Unfortunately, my attempt at modification (shown below) did not work. The use of classList.replace should change all instanc ...

Ensuring the input field and button are positioned in a horizontal line

Currently, I am developing a to-do list application using React and Chakra UI. I am trying to align the input field and the button on the same line for a more organized layout. This is the current layout: image I aim to achieve a design similar to this: ...

Finding strikeout text within <s> or <del> tags can be identified by closely examining the HTML codes

The issue arises with the text that reads as follows: 316.6.1 Structures. Structures shall not be constructed This is represented in HTML as: <b> <s> <span style='font-size:10.0pt'>316.6.1 Structures</span> ...

React powered interactive tables

I am in the process of creating a dynamic table using React, and here is the data structure I am working with: { numRows: 2, numCols: 3, cells: [ { id: 1, pos: { row: 1, col: 1 }, content: 'This is th ...

Lacking HTML5 support, your current location cannot be accessed on Google Maps

I have implemented google maps on my basic HTML website. Currently, I am able to center the map based on the user's current location using HTML5, however this requires obtaining permission from the user. Interestingly, when I visit maps.google.com, th ...

Is there a way to reposition a popup window to the center of the page after launching it?

popup = window.open(thelink,'Facebook Share','resizable=1,status=0,location=0, width=500,height=300'); My goal is to perfectly center this popup window both vertically and horizontally. ...

Tap to smoothly scroll through each block using the animate() function

ul { padding: 0; margin: 0; height: 180px; overflow: auto; } li { height: 50px; background: pink; list-style: none; margin-bottom: 10px; height: 50px; ...

What is the best way to switch between search results shown in an li using AngularJS?

Looking for a way to toggle a list that appears when a user searches in my app. I want the search results to hide when the search bar is closed. How can I achieve this? I think Angular might be the solution, but I'm stuck on how to implement it. I tri ...

The MVC 5 view is unable to display an HTML image when adding it within an appended div

Currently, I am working with ASP.net MVC5 at a novice level. I'm faced with the challenge of creating a div that displays an image using a JavaScript function. Here is the code snippet I have: function showLoadingImage() { $('#submit_Em ...

Struggling to locate element using Selenium in Python 3?

While using Selenium for WebScraping, I've encountered difficulty detecting an element using xpath, full xpath, id or text. <div id="cbp-vm" class="cbp-vm-switcher cbp-vm-view-list"> <div class=cbp-vm-options">...& ...

How to keep jQuery horizontal submenu open when clicking on the menu

Seeking assistance with a menu issue. I have a horizontal menu with subitems that display when clicked, but having trouble with the submenu behavior. When clicking on a submenu item, I want it to remain open and show the related items underneath it. For ex ...

Chromium CSS blend mode problem

Can anyone help me create a Photoshop overlay effect on my website? My code works perfectly in Firefox, but it's not functioning correctly in Chrome. Here's the demo. This is my current code: HTML <img src="http://lorempixel.com/output/fash ...

The importance of scope in ng-style

I am attempting to dynamically change the font color in an input field based on the value entered into that field. However, I have encountered an issue with using ng-style as it is not recognizing the value of the scope and therefore the color does not upd ...

The main menu vanishes when you hover over it after the affix class is activated

I am currently working on creating a horizontal dropdown menu that expands on mouseover and collapses on mouseout under one of the main menu items. The functionality of this effect is working fine, except for one issue. When I scroll down and activate the ...

What methods can I use to eliminate an iframe virus that has infected all my PHP files on my website?

I'm facing a challenge with eliminating a virus code from my php files. All 1200+ php files on my server have been infected by this malicious code, which injects the following line into the html output: Here is the virus code: <tag5479347351>& ...

Material UI drop down select position placement

Having an issue with the dropdown position when using select from material UI. It's not appearing in the correct location. Desired Dropdown Position: https://i.sstatic.net/arRIF.png Current Dropdown Position: when opening the dropdown https://i. ...