Filling a table cell with a div that spans 100% height

I am currently working with Bootstrap and I am attempting to create three columns filled with text overlaying a rectangle. The squares within the columns should have equal height and there needs to be spacing between them.

Through the use of display:table; and display:table-cell; properties, I have managed to ensure that the col- divs have uniform height. However, I am facing difficulty in making the inner div completely fill its parent. Any insights on how this can be achieved would be greatly appreciated.

Here is the code snippet:

<div class="container">
  <div class="fons"></div>
    <div class="linia">
      <div class="col-md-4">
        <div class="dins">
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
        </div>
      </div>

      <div class="col-md-4">
        <div class="dins">
          <p>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.</p>
        </div>
      </div>

      <div class="col-md-4">
        <div class="dins">
          <p>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.</p>
        </div>
      </div>

    </div>

</div>

Additionally, here is the associated CSS styling:

.fons {
  background-color: blue;
  height: 100px;
  }

.linia {
    display: table;
    margin-top:-50px;
  }

.col-md-4 {
    display: table-cell;
    float:none;
  }

.dins {
    background-color: cyan;
    padding: 15px;
  }

The main query revolves around ensuring that the .dins div fills up the entirety of its parent table cell.

You may view a demonstration that I have created using the following link: https://www.bootply.com/dId7aMpOcX

Answer №1

try out this snippet of code

.container {
  width:100%;
}

alternatively, you could apply the styling directly to the div

<div style="width:100%">

Answer №2

https://i.stack.imgur.com/m1XKN.png

try out this snippet of code

<div class="container">
      <div class="fons">
        <table width="100%">
          <tr><td>
            <div class="linia">
     <div class="col-md-4">
            <div class="dins">
              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
            </div>
              </div></div></td>
            <td>
            <div class="linia">
     <div class="col-md-4">
            <div class="dins">
              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
            </div>
              </div></div></td>
            <td>
       <td>
            <div class="linia">
     <div class="col-md-4">
            <div class="dins">
              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
            </div>
              </div></div></td>

          </tr>
        </table>][1]][1]

</div>

Answer №3

Instead of using col-md-4, you have the option to simply use a division element. See below for the code:

<div class="linia">
  <div class="dins">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="dins">
      <p>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.</p>
    </div>
    <div class="dins">
      <p>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.</p>
    </div>
</div>

CSS Styles:

.linia {
 display: table;
 margin: 0px -15px;
 border-spacing: 15px;
}
.dins {
 background-color: cyan;
 padding: 15px;
 display: table-cell;
 height: 100%;
 width: 33.33334%;
}

Answer №4

One option is to set a minimum height for your din classes.

   .dins {
    background-color: blue;
    padding: 20px;
    min-height:200px;
  }

Alternatively, you can explore other solutions by visiting How to make Bootstrap columns equal height

Answer №5

Consider trying out the flex property :

Check out this Plunker Link for reference : https://plnkr.co/edit/VJFOdwLjgBk9rpGP5KYQ?p=preview

<div class="container">
  <div class="fons"></div>
  <div class="linia">

      <div class="dins">
        <p>Showing dummy text here, adjust as needed: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>


      <div class="dins">
        <p>More dummy text for demonstration: 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.</p>
        <p>Additional dummy text to showcase flex implementation: 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.</p>
        <p>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.</p>
      </div>


      <div class="dins">
        <p>Another set of dummy text for illustration purposes: 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.</p>
      </div>


  </div>
</div>

CSS :

.fons {
  background-color: blue;
  height: 100px;
}

.linia {
    display: flex;
    margin-top:-50px;
    box-sizing : border-box;
}

.dins {
    background : cyan;
    margin: 15px;
    padding : 15px;
}

Answer №6

Please review the following code structure: https://jsfiddle.net/c0mcwbph/

<div class="container">
<div class="fons"></div>
<div class="linia-wrapper">
<div class="linia">
<div class="col-md-4">
<div class="dins">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="col-md-4">
<div class="dins">
<p>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.</p>
</div>
</div>
<div class="col-md-4">
<div class="dins">
<p>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.</p>
</div>
</div>
</div>
</div>
</div>

CSS

.fons { background-color: blue; }
.linia-wrapper { display: table; width: 100%; }
.linia { display: table-row; }
.col-md-4 { display: table-cell; float: none; }
.dins { background-color: cyan; padding: 15px; }

Answer №7

After trying various solutions, I found that Solution 1 here partially solved the issue by avoiding rounded corners on the div's bottom.

Although Solution 2 seemed more efficient in theory, it did not fully resolve the problem as expected.

Now, the correct solution code that is working flawlessly can be found here: https://www.bootply.com/dId7aMpOcX

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

Overflow of Div Content

I need a way to showcase a collection of around 30 links in a horizontal layout without the links wrapping to a new line if they exceed the width of the parent container. A horizontal scroll should appear for users to navigate through the overflowing links ...

Ways to define the background color of a form group

I am trying to customize the background color of a form-group element. To illustrate my point, take a look at the image below In the image above, I have highlighted the div in question and I want to change its background color from within the form-group. ...

The opacity of each div within a container increases as you move from one div to the

I am striving to craft a series of divs that feature varying levels of opacity in their background colors, creating a gradient effect. In an attempt to achieve this, I utilized a variable linked to the ID of each individual div. Unfortunately, my efforts ...

Utilizing CSS to create a zoom effect on hover for an image while preserving its original size was successful, however, the issue arises as only a corner of the image is visible

On my webpage, I have implemented an image that zooms in slightly when hovered over. Unfortunately, this animation has caused the image to only display one part regardless of whether hover is activated or not. I've attempted to troubleshoot by adjusti ...

What causes TypeScript to interpret an API call as a module and impact CSS? Encountering a Next.js compilation error

My website development process hit a roadblock when I tried integrating Material Tailwind into my project alongside Next.js, Typescript, and Tailwind CSS. The compilation error that popped up seemed unrelated to the changes, leaving me baffled as to what c ...

Replace minor components (SVG) within the primary SVG illustration

I'm interested in transforming SVG elements into the main SVG element. For example, let's say the black square represents the main SVG element. I want to change elements 1, 2, and 3 to different SVG elements using JavaScript code. However, I am u ...

Trouble with sending SMTP emails from Flask app (Error 500)

Currently, I am in the process of developing a website using Python and Flask where I have successfully implemented a Contact Form Modal. The modal opens up smoothly allowing me to fill it out (many thanks to the supportive community <3), however, upon ...

Troubleshooting the Gutter Problem in jQuery Isotope and Masonry

Currently, I am utilizing the Isotope jQuery plugin. While it is a fantastic tool, I am encountering a minor issue with aligning items in masonry mode. The width of my container is 960px, and I aim to have 4 items perfectly aligned as if they were adhering ...

HTML/CSS - Enhances user experience by zooming in on select tag when tapped on mobile devices

I am experiencing an issue with a select menu on mobile devices. Whenever I tap on the menu, it seems to zoom in slightly. Is there a particular -webkit property causing this behavior? How can I prevent the screen from zooming when I tap on the select me ...

implementing jquery typewriter plug-in for a responsive bootstrap image

I am using Bootstrap and my image response dynamically, but I am having trouble adding text to it. I would like to use a jQuery typewriter plugin for the text on the image, which should resize according to screen size. Here is my HTML code and I have used ...

What happens when there is no match found while attempting to edit a form with the UI-Bootstrap typeahead directive?

Here is the code that demonstrates how my typeahead input box functions. Users can enter a name, and the relevant information will populate the rest of the form. If no match is found, users should still be able to input the name and related details into th ...

Default behavior in Fullcalendar 6 allows for rendering links on both days of the month and weekdays

Is there a way to customize the rendering of days and weekdays in Fullcalendar React? Currently, they are displayed as links by default (<a>{dayContent}</a>), but I'm looking to have them rendered as <div> or <span>. Any sugges ...

Eliminating render-blocking CSS in PageSpeed - one stylesheet at a time

Currently, I am testing the best optimization practices for front-end development. As part of this process, I have utilized gulp and npm to merge and minify my CSS and JS files into a single all.min.css and js.min.css file. Upon analyzing my website using ...

Unicef's animated web content

Looking to learn more about gate animation and zoom page transition on the Unicef website? I want to incorporate these cool animations into my own project. Can someone provide me with a "keyword" or point me in the right direction to find information on ...

Disable the default form input reset button generated by Internet Explorer 10

Just have one field form for search input. Below is the HTML code: <form class = "search-form hide-on-mobile"> <input class = "global" type = "text" placeholder = "Who are you looking for ?"> <but ...

Looking to create a row-column-row layout using CSS flexbox techniques

` I am trying to create a unique row-column-row layout using CSS flexbox. Below is the code snippet I have: * { padding: 0; margin: 0; box-sizing: border-box; } .container { display: flex; flex-wrap: wrap; gap: 0.2%; } .box { color: whit ...

Executing a JavaScript function within a PHP echo statement

I am completely new to working with AJAX and PHP echo variables or arrays. However, I have managed to successfully display images on my website by passing variables from AJAX to PHP and back. The only problem I am encountering is when I try to call a Javas ...

I'm having trouble with my Typescript file in Vscode - every time I try to edit the css code, all the text turns red. Can someone

Check out this visual representation: [1]: https://i.stack.imgur.com/9yXUJ.png Followed by the corresponding code snippet. export const GlobalStyle = createGlobalStyle` html { height: 100%; } body { background-image: url(${BGImage}); ba ...

A guide to building a dynamic form slider that showcases variable output fields with Javascript

I'm interested in creating a Slider Form that shows different output fields when sliding, using Javascript. Something like this: Could anyone provide suggestions on how to achieve this or share any links related to something similar? I haven't b ...

Guide for creating a scroll-triggered rotation animation using only JavaScript

Looking to achieve a cool scroll effect with an image that rotates on the X-axis by a specific degree, such as 70deg. The goal is to have the image's rotateX value change to 0deg when it enters the viewport upon scrolling and revert back to 70deg whe ...