Issue with Bootstrap DIV not extending to full height when applying background-color

I have encountered numerous posts on this topic, but none of the solutions provided have worked for me. I must admit that I struggle to grasp CSS concepts, although I am making an effort to learn.

Here is the code I am currently using:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Question Form Modal</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<style>
    .QuestionFormLeft {
        background-color:white;
    }
    .QuestionFormRight {
        padding-top: 0;
        background-color:#DBDDDE;
        height: 100%;

    }
    .QuestionFormRight p:first-child {
        margin-top: 20px;
    }
    .QuestionFormRow {
        border-bottom: 3px solid #DBDDDE; 
    }
</style>
<div class="container-fluid">
  <div class="row QuestionFormRow">
    <div class="col-sm-4 QuestionFormLeft">
        <h4>Question 1 Title</h4>
        <p>Some words and description. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
    <div class="col-sm-8 QuestionFormRight">
        <p>Please select an option from below:</p>
        <select>
            <option>Awesomeness</option>
            <option>Greatness</option>
        </select>
    </div>
  </div>
  <div class="row QuestionFormRow">
    <div class="col-sm-4 QuestionFormLeft">
        <h4>Question 2 Title</h4>
        <p>Some words and description. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
    <div class="col-sm-8 QuestionFormRight">
        <p>Please select an option from below:</p>
        <select>
            <option>Awesomeness</option>
            <option>Greatness</option>
        </select>
    </div>
  </div>

</div>

</body>
</html>

Link to code on JSFiddle: https://jsfiddle.net/dwzndscm/

I am seeking assistance on how to make the Right DIV QuestionFormRight fill the background with 100% height. It is important to note that the page width automatically adjusts, so stacking left to right is preferred over top to bottom.

While I could easily achieve this with a table, I am trying to avoid taking that route. Any help or guidance on this matter would be highly appreciated.

Answer №1

If you want to ensure that .QuestionFormRight can expand equally, you can utilize CSS flexbox with the flex: 1 property. Check out the code snippet below for a functional example.

Hopefully, this solution proves to be beneficial for you.

.QuestionFormLeft {
  background-color: white;
}

.QuestionFormRight {
  padding-top: 0;
  background-color: #DBDDDE;
  display: flex;
  flex: 1;
  align-items: flex-start;
  flex-direction: column;
}

.QuestionFormRight p:first-child {
  margin-top: 20px;
}

.QuestionFormRow {
  border-bottom: 3px solid #DBDDDE;
  display: flex;
  flex-wrap: wrap;
  flex: 1;
}
<html lang="en">

<head>
  <title>Question Form Modal</title>
  <meta charset="utf-8>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body>

  <div class="container-fluid">
    <div class="row QuestionFormRow">
      <div class="col-sm-4 QuestionFormLeft">
        <h4>Question 1 Title</h4>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
      </div>
      <div class="col-sm-8 QuestionFormRight">
        <p>Please select an option from below:</p>
        <select>
            <option>Awesomeness</option>
            <option>Greatness</option>
        </select>
      </div>
    </div>
    <div class="row QuestionFormRow">
      <div class="col-sm-4 QuestionFormLeft">
        <h4>Question 2 Title</h4>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
      </div>
      <div class="col-sm-8 QuestionFormRight">
        <p>Please select an option from below:</p>
        <select>
            <option>Awesomeness</option>
            <option>Greatness</option>
        </select>
      </div>
    </div>

  </div>

</body>

</html>

Answer №2

You should consider trying out the CSS property height: 100vh. I recently tried it out and it seemed to solve my problem. Unfortunately, the link to your jsfiddle doesn't seem to be functioning properly.

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

Is it possible to turn off wrapping behavior within a div using CSS3 or Bootstrap?

Currently, I am working with code that utilizes Bootstrap 2. <div class="row-fluid"> <div class="span4">Some text 1</div> <div class="span4">Some text 2</div> <div class="span4 ...

Angular for user authentication page

I've been busy working on the login page, and I've managed to create a login UI that meets the requirements. However, I'm facing some challenges when it comes to validating the username and password. Being new to Angular and Web API, I might ...

Set the background of the div element behind the image

I am trying to create a layout where the div color matches the size of an image behind it, with the image moving slightly on hover. Here is my code: <div class="row text-center about__gallery"> <div class="col-xs-12 col-sm-4"> <div cl ...

Looking to update the meta tags for a specific page in Next.js using the Head component?

In my project using next js 13 with pages structure, I have set up _document with meta tags and title for global pages using Head. However, I am now facing an issue where I want to define specific meta tags and title for a single page called "one". Despite ...

Align Bootstrap 4 dropdowns with their parent element

Is there a way to match the width of a bootstrap dropdown menu with its parent input group? <div id="ddl_1" class="input-group"> <input type="text" class="form-control "> <div class="input ...

Retrieve the most recent information from the database based on a specific column

Is there a way to retrieve only the most recent row from each category in the database? Example Database: Table name: Colors id category timestamp 1 yellow 14/2/2014 2 blue 13/2/2014 3 red 14/2/2014 4 yellow 13/2/2014 5 blue 11/2/2014 ...

Class for Eliminating the Background Image Using Bootstrap

Is there a Bootstrap class that can be used to remove a background image from a div? Currently, I have this style defined in my CSS: background-image: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0)); I would like to remove it using: bg-img-non ...

Having trouble making `overflow: hidden` work correctly when using padding on an element with `height:

Looking for some coding help here. My aim is to create a customized select menu with a sleek animation effect. I initially decided to set the default height to 0 and use overflow: hidden, then switch it to auto when .active class is applied. But, I'm ...

Adjust the filter settings in angularJS

I am working on a request page with three buttons: Open, Close, and All. Currently, when the page is opened, it displays the 'All' requests by default. However, I want to change this to show the 'Open' requests instead. I want users to ...

"Composing perfect sentences: The art of incorporating quotes

I am attempting to include text with quotes in a DIV, like so: "All is well that ends well" The text is generated dynamically and I'm using a JavaScript font replacement plugin (CUFON) to add quotes around the text. Sometimes, the ending quote drops ...

Creating a Dynamic Layout with Varying Items in an Array Using PHP

Suppose I provide you with an array of objects, where x represents the number of objects. How would you achieve the following using a grid system (bootstrap, foundation, etc.)? Loop over the array and generate something similar to: https://i.sstatic.net/ ...

What strategies can be implemented to decrease the value of the writing box by 2.5%?

I would like to decrease the value in the input box by 2.5%. Here is the HTML code snippet: <div class="ZakatCalc"> <div class="calcimg"> <img src="" alt="" srcset="" class=" ...

Utilizing Bootstrap 4: Opting for <select> over tabs (<li>)

Is there a way to customize the appearance of Bootstrap tabs by replacing them with a dropdown select menu instead of the standard tab layout created with <ul> and <li> elements? I am working with a relatively small area (such as col-3) where ...

What is the best way to utilize CSS to center an element in relation to the scroll bar?

For a group project, I successfully centered a div on a webpage. However, I ran into an issue where the website's contents are centered taking the scroll bar width into consideration. This means that the web page contents adjust to be centered without ...

What is the best way to implement conditional styling in Vue.js?

Looking to incorporate a conditional style into my Component. Here is my component: <site-pricing color="primary" currency="$" price="25" to="/purchase" > <template v-slot:title>Complete</templat ...

How can JavaScript be used to remove HTML tags from text while preserving a space between each line?

I found a helpful solution on Stack Overflow for removing HTML from text content. This is the method it suggests: function strip(html){ let doc = new DOMParser().parseFromString(html, 'text/html'); return doc.body.textContent || "&quo ...

Facing compatibility problems with JavaScript and Cascading Style Sheets in Google Chrome?

Welcome to the site . Let's address a couple of issues with JavaScript and CSS: Firstly, the JS code seems to be malfunctioning only in Chrome, throwing an error that reads: 'Uncaught TypeError: Object [object Object] has no method 'on prij ...

displaying a shadow solely on the left side of an image

When using jQuery to append an img element and apply a box-shadow on click, I am only seeing the shadow appear on the left side of the image. How can I make the box shadow show up on all sides of the image? var someNumbers = [1, 2, 3]; $.each(someNumbe ...

What is the method for aligning the cursor in a text input field with a placeholder in Edge without using JavaScript?

Does anybody have a solution for making this work in all browsers, except for Edge? I'm looking for a pure CSS workaround. input { text-align: center } <input placeholder="placeholder" /> ...

Can I specify which modal or component will appear when I click on a component?

Working on a small Angular 5 project, I have a simple component that represents a food product shown below: [![enter image description here][1]][1] This component is nested within my main component. When this component is clicked, a quantity component/m ...