CSS Trick: Positioning All Div Children at the Bottom

I have been attempting to align all the children of a div to the bottom, but so far have not been successful. I tried using the display: table and table-cell method that I found online, as well as some other methods, but none seem to work for me. You can find my code structure and a link to it here:

HTML:

<div class="a">
  <div class="c"></div>
  <div class="b">
    <div class="al" style="background:green;"></div>
    <div class="al" style="background:blue;"></div>
    <div class="al" style="background:tan;"></div>
  </div>
</div>

CSS:

.a{
  float: left;
  background: red;
  display: table;
  padding-right: 1px;
  height: 100%;
}
.b{
  position: relative;
  float: left;
  background: blue;
  display: table;
  height: 100%;
  width: 29px;
}
.c{
  height: 300px;
  width: 90px;
  background: grey;
  float: left;
}
.al{
  margin-top: 2px;
  background: yellow;
  display: table-cell;
  width: 100%;
  height: 30px;
  padding: 20px;
  vertical-align: bottom;
}

You can check out the full code on CodePen

Answer №1

To make the contents of .b align to the bottom, you can use the following CSS:

.b {
  display: table-cell;
  vertical-align: bottom;
}

Check out the full code snippet below:

.a {
  display: table;
  padding-right: 1px;
  background: red;
}
.b {
  display: table-cell;
  vertical-align: bottom;
  width: 29px;
  background: blue;
}
.c {
  display: table-cell;
  height: 300px;
  width: 90px;
  background: grey;
}
.al {
  margin-top: 2px;
  height: 30px;
  padding: 20px;
}
<div class="a">
  <div class="c"></div>
  <div class="b">
    <div class="al" style="background:green;"></div>
    <div class="al" style="background:blue;"></div>
    <div class="al" style="background:tan;"></div>
  </div>
</div>

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

Placing text on top of an input field using HTML and CSS

I am currently in the process of creating a website for my high school that will allow students to access their class schedules online. To differentiate each class, I have assigned them different background colors. This is achieved on the main page by adju ...

Why do all the values in my table turn into input boxes when I click the edit button?

When working with my HTML, I am using ngFor to iterate through a list of items and display them in a table. However, when I try to edit an item by clicking on it, the input box opens but all the table rows display the same value. <tr *ngFor="let item o ...

Difficulty arises when trying to engage with the addition span within a span using jQuery

Looking for some assistance here! Currently in the process of developing a mail system and focusing on creating a list of receivers. I am working on adding user names to a span element, with the goal of being able to remove users by clicking their name. & ...

Why are all the values in my list appearing as undefined after parsing with JSON?

Just starting out with this project. I'm attempting to print a list, where the names come from a button. However, all the names are showing up as undefined. I suspect it has something to do with local storage, but I can't pinpoint the issue. < ...

Customizing CSS color to blend seamlessly with Bootstrap's theme

Currently, I am in the process of creating a new CSS class with a background color similar to the one used in Bootstrap's "bg-primary" class. Although I have looked through the documentation and learned that using the color as a variable in other CSS ...

Designing a charcoal square div featuring a see-through circular element at its center

I'm working on a design concept that involves creating a square div with a transparent circle in the center. The idea is to have an image as the background, with the transparent circle acting like a window through which the background image can be see ...

Utilize the `document.getElementById` method to trigger both function 2 and form 2 when clicked

Hey there, I'm having some issues with my code and would appreciate some help. After a user submits my form with the ID of 'fwrdform' using the onclick event, I want to also trigger another function from my 'logout-form' so that t ...

assigning attributes to web addresses

Is there a way to set a style property for webpages by targeting addresses that contain /index.php/projecten/ instead of specifying each complete address in the code? Currently, I am using the following code: <ul class="subnavlist" style="display: &l ...

Issues with Media Queries on Desktop Devices

I've encountered an odd issue with my media queries. While they function properly on my mobile devices, resizing my desktop browser doesn't seem to trigger the changes. This prevents me from inspecting my mobile styles using web inspector/firebug ...

Update the hover functionality to only trigger on small screens when clicked

Is there a way for the text content to change from appearing on hover of an image to opening with a click in the mobile version? <div class="program prog-image" style="background-image: url(https://imagevars.gulfnews.com/2019/07/23/Timberwolf_16c1de355 ...

How to dynamically style NavLink using a variable in react-router-dom with Emotion?

Is there a way to extract styles to a variable when using react-router-dom's NavLink activeStyle prop? I want to avoid repeating the same styles without using a css file. Ideally, I would prefer to achieve this using Emotion, but if that's not f ...

What materials are required in order to receive messages and information through my Contact page?

Currently, I am pondering the optimal method for gathering information from my Contact page. I have already created a form; however, I'm unsure how to send the gathered data to myself since I am relatively new to Web development. Angular is the framew ...

Issue with Selenium WebDriver: Expectation failure while waiting for element visibility at specified location(..)

I'm facing a little issue with my automated test. Whenever the test encounters an error like this: Expected condition failed: waiting for visibility of element located by(...) I find it difficult to pinpoint the exact problem. @BeforeMethod pub ...

How to set a background image using CSS in a Node.js application with Express

I'm currently delving into Node.js and as a total newbie, I haven't been successful in finding a solution. This is my directory structure: app --> public --> a.jpg & style.css When I provide access to these files in Express, it's ...

css The max-width property appears to be malfunctioning

My parent element has a width of 100px and a position of relative. Inside it, there is an inner element with a position of absolute. I want this inner element to stretch out up to 200px, but for some reason, it's not working. The maximum value it take ...

Execute an AJAX request and dynamically update the page when the button is clicked simultaneously

Hello everyone, I'm a beginner in ajax and I'm encountering an issue with executing JavaScript when a button is clicked. What I'm trying to achieve is, when the button is clicked, I want to run an ajax function to call a PHP script for query ...

The spacing in MUI Grid results in the grid having extra left padding

I'm having trouble creating a grid with a group of elements, specifically when I try to add spacing between them. Take a look at the image below with spacing={0} set on the Grid container: No spacing in Grid container Now, here's what happens wh ...

Picture goes missing from slideshow

I am currently using a CSS + Javascript slideshow on my website, inspired by an example from the W3Schools website. Here is the code I have adapted for my web application: $(document).ready(function() { var slideIndex = 1; function showSlides(n) { ...

"Form submission fails to populate _POST when file and text fields are used simultaneously

Looking for a solution... <form action="upload.php" method="get" enctype="multipart/form-data"> Enter a 10 digit mobile number: &nbsp;<input id="imgphno" type="text" maxlength="10" /> <br/><br/> <input id="file" type="file" ...

Tips for Updating HTML Table Content Dynamically Using JavaScript without jQuery

I am in the process of developing a web application that requires me to dynamically change the content of an HTML table based on user input, all without relying on jQuery or any other external libraries. Adding rows to the table is not an issue for me, but ...