The div element should stretch to occupy the entire height of the screen

I have structured my webpage with three different divs. The left one is defined with col-md-2, the middle one with col-md-8, and the remaining right div with col-md-2. I want the right div to take up 100% of the screen height, even when no controls are present. I have tried setting both height and min-height to 100%, but it doesn't seem to be working. Here is a snippet of my code. Can anyone advise me on how to resolve this issue?

<div id="propertiesContainer" class="row col-md-2" style="border:solid 1px;padding-left:unset;padding-right:unset;min-height: 100%;height:100%;"></div>

Answer №1

Make sure to set the body, html, container, and row elements to 100% as well.

Keep in mind that a div will only take up 100% height (without any content inside) if its parent element is also set to 100% height.

html,body{
 width:100%;
 height:100%;
}
.row div{
  height:100px;
  background-color:red;
}
.row, .container{
  height:100%;
}
.row .right{
  height:100%;
  background-color:green;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="row">
    <div class="col-xs-2"></div>
        <div class="col-xs-8"></div>
        <div class="col-xs-2 right"></div>
    </div>
</div>

Answer №2

If you want to make an element's height 100% of the screen's height, each parent of that element must also have a height of 100%.

For Example

@import url(https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css);

html,
body {
  height: 100%;
}

.main {
  height: 100%;
}

.main .side {
  height: 100%;
}

/*/ Decoration /*/
body {
  background-color: #ffeeff;
}

.main {
  border: dashed 1px blue;
}

.main div {
  border: dashed 1px red;
}
<div class="container main">
  <div class="col-xs-2">
    Left
  </div>
  <div class="col-xs-8">
    Center
  </div>
  <div class="col-xs-2 side">
    Right
  </div>
</div>

Answer №3

<div class="new-class">
</div>

CSS

.new-class{
    max-width: 100%;
}

or 
.new-class{
   width: 100%;
}

Answer №4

Feel free to share your code on Fiddle for better assistance, or you can refer to the example code provided below:

.main-content{
  position:relative;
  display:flex;
  height:100%;
  background: #f8f8f8;
  justify-content:center;
}

html, body{
  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 determine if a date is empty using Vuetify?

Could someone help me with checking if a date was entered by the user? I want to display an error message if a date is not provided. I attempted to use a rule for this purpose, but unfortunately it's not showing any error message. Below is the code I ...

Creating a bold portion of a string

My task involves dynamically creating <p> elements within a div based on the contents of my codeArray, which can vary in size each time. Instead of hard-coding these elements, I have devised the following method: for(i=1;i<codeArray.length;i++) ...

Working with both Javascript and jQuery code within a single HTML file

I recently created a website and on one of the pages, I added some jQuery elements like a start button and progress bar. However, when I tried to implement a JavaScript timer on the same page by adding the script into the header, the jQuery elements stoppe ...

Press the [Submit] button to conceal DIV Container 1, reveal DIV Container 2, and populate DIVs discovered in a .PHP file within DIV Container 2

Trying to achieve the following steps: 1 - Press Submit Button 2 - Conceal DIV Container 1 3 - Reveal DIV Container 2 4 - Load and display all DIVs from "PricingDisclaimer.php" into Div Container 2 DIV Code snippet: <div id="MainContainer"> &l ...

Why is my main.scss having trouble importing other files?

I am experiencing issues with importing my scss file. First, I created a file called main.scss and added some code to it. All the codes are functioning properly and showing up on the webpage. Next, I created two folders named settings and elements. In ...

Control your thumbnails with the powerful iDangerous Swiper feature

Are you new to coding? I'm looking for help on linking thumbnail images to a swiper so that when a thumbnail is clicked, it moves the swiper-container to the corresponding slide. Any ideas or suggestions would be greatly appreciated! Here's an e ...

What is the best way to present sorted items on a user interface?

I have a unique Med interface containing properties like drugClass, dosage, and name. Using this interface, I created an array of drugs with different attributes. How can I filter this array by drugClass and then display the filtered data on a web page? ...

Update the CSS property according to the selected list item in the slider using Glider JS

Looking to dynamically change the background image in CSS based on the active slide value in Glider.js Here is the CSS: html { background-image: url("https://images.unsplash.com/photo-1496518908709-02b67989c265?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEy ...

Transform preexisting Vue UI library measurements into pixels

I was curious about converting all existing units (em / rem) to pixels. How can I easily convert the entire output units to px? Are there any tricks or methods available? Currently, I am utilizing Vuesax UI to create a plugin for various websites and temp ...

Tips for Including a Parallax Image Within a Parallax Section

Currently, I am working on implementing a parallax effect that involves having one image nested inside another, both of which will move at different speeds. My progress has been somewhat successful, however, the effect seems to only work on screens narrowe ...

Creating a dynamic dropdown menu based on a class value using JavaScript in PHP

There are two dropdown menus on my webpage that display information from my SQL table. The first dropdown contains different "Colors," and the second dropdown contains members associated with each color group. Each member is categorized into different optg ...

Is there a downside to concealing a checkbox off-screen using position: absolute for a clever workaround?

I recently came across a clever trick known as the checkbox hack, which involves hiding checkboxes on web pages by positioning them off-screen. The example provided on CSS Tricks demonstrates this technique with the following code: position: absolute; top ...

Ways to remove unwanted line breaks following PHP code within HTML documents

Currently working on building my blog, and I'm facing some challenges with the post div. It seems like every element within is automatically getting line breaks. Despite trying to float them or adjust padding, it's not giving me the desired layou ...

Unable to retrieve the value of ng-model using $scope

Having some trouble getting the ng-model value when clicking a button that triggers a function to add each ng-model value to an object. Interestingly, when trying to get the value of $scope.shipNameFirst, it shows up as undefined in the second example. I& ...

The submission of the form is not functioning correctly when triggered by JavaScript using a button

My website was designed using a CSS/HTML framework that has been seamlessly integrated into an ASP.NET site. Within a ContentPlaceHolder, I have implemented a basic login form. The unique aspect is that I am utilizing the onclick event of an image to subm ...

How can I efficiently verify page references using tools like CSS, JavaScript, and more?

I have Firebug (my team lacks Firefox) and the IE developer toolbar (IE7), but I'm struggling to easily validate if the referenced files in a page are loading. I see Javascript errors, but they don't lead me directly to the exact file in the hier ...

Move your cursor over the image to activate the effect, then hover over it again to make the effect disappear

Looking to enhance my images with hover effects. Currently, all the images are in grayscale and I'd like to change that so that when you hover over an image, it reverts to full color and remains that way until hovered over again. I've noticed so ...

Reveal or conceal interactive material using data attributes

I am having difficulty in achieving a certain functionality on my website. Here is the HTML code I am using: <div id="menu"></div> <ul class="countries"> <li data-country="country-1" data-countryname="France">Category France</ ...

Image carousel with variable height

I'm attempting to implement a slide show of images with previous and next functionality. When the user clicks "previous," I want the images to slide to the left, and when they click "next," I want the images to slide to the right with a 0.5 second del ...

The challenge of margin collapse

I am currently working on resolving a margin collapse issue. I am puzzled by the overlapping paragraphs and I really need to understand why this problem is happening. I suspect it may be a collapsing margin issue. Please take a look below: https://i.sta ...