Position floating divs at the bottom of the page

Check out this example on JSFiddle: I'm trying to make the left column align to the bottom, but I can't seem to figure it out.

http://jsfiddle.net/magwalls/rdrznzhe/

<div width="100%" class="clear">
  <div class="fl" width="50%">I want this aligned at the bottom</div>
    <div class="fr" width="50%">
      <div>Row 1</div>
      <div>Row 2</div>
      <div>Row 3</div>
    </div>    
</div>
<hr class="clear"/>

UPDATE: I've made some changes based on Vitorino and Danko's solutions in my updated JS Fiddle here. http://jsfiddle.net/magwalls/rdrznzhe/12/

Answer №1

From my understanding, the vertical alignment of floated elements cannot be set directly. However, one alternative is to use inline-block and float other elements as a workaround:

.fl, .fr {
    display:inline-block;
    vertical-align:bottom;
    width:50%;
}
.fr > div {
    float:right;
    clear:right;
}

To see this in action, check out this Demo Fiddle


Keep in mind that when using inline-block, you may need to address the space between elements. Here is a helpful resource on handling this issue: CSS TRICKS. In this case, I have used the comment <!-- -->

Answer №2

Here is a suggested solution:

Check out the JS Fiddle example

.fl {
position:absolute;
bottom:0;
}

.wrap{
width:100%;
display:inline-block;
position:relative;
}

We have added the .wrap class to the

<div width="100%" class="clear wrap">
(parent div) in order to clear the float of .fr or it will have a height of 0px.

Answer №3

Let's change things up a bit by using the display: table property and making some adjustments to your HTML structure. Here's how we can lay it out:

<div class="table">
    <div class="cell left">I will be vertically aligned at the bottom</div>
    <div class="cell">I will consist of three rows</div>
</div>

Now let's tackle the CSS. Feel free to make any necessary tweaks. In this scenario:

  • html,body { height: 100%; } allows the wrapper div to have a percentage-based height

  • The wrapper div is styled with display: table, height: 100%, and width: 100%

  • The two "columns" use display: table-cell to function as columns

  • The left column has vertical-align: bottom applied

  • .cell > div selects direct child div elements of the .cell class, each being assigned a height of 33.33% for even distribution across rows

CSS / HTML / Demo

html, body {
    height: 100%;
}
body {
    margin: 0;
}
.table {
    display: table;
    height: 100%;
    width: 100%;
    border-bottom: solid 1px #333;
}
.cell {
    display: table-cell;
    vertical-align: top;
    width: 50%;
}
.left {
    vertical-align: bottom;
    height: 100%;
    border-right: solid 1px #333;
    background: #DDD;
}
.cell > div {
    height: 33.33%;
    background: #EEE;
    border-bottom: solid 1px #333;
}
.cell > div:last-child {
    border-bottom: none;  /* no border for the last child */  
}
<div class="table">
    <div class="cell left">This should be aligned at the bottom</div>
    <div class="cell">
        <div>Row 1</div>
        <div>Row 2</div>
        <div>Row 3</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

Why do I need to double-click? (JavaScript onclick event handler)

As a beginner in JavaScript and web development, I encountered a peculiar issue for the first time. In a simple example, I have two divs - left and right. The left div contains five images, while the right div is empty. There are two buttons - copy and del ...

Encase a group of child elements within a parent container using

Currently, I am able to wrap an entire li-element in an ordered list with a link: $(e).wrap('<a href="#" onclick="window.open(\'/xyz/\');return false;"></a>'); This is the HTML construct: <li class=""> ...

Indicate the initial position of the scroll bar

Currently, I am working on implementing scrolling functionality and attempting to start it at a specific element based on a given id. This is how my html code looks like: <div class="list-wrapper" style="max-height:350px;overflow-y:scroll" > < ...

In Chrome, the latest SVG border-image-source is not functioning properly

For the past 6 months, I successfully used border-image-source to create a custom border on one of my websites. Recently though, I noticed that it no longer appears in Chrome, although it still works in Safari. Here is the code snippet I have been using: ...

What is the reason behind H1 tags not requiring a class or ID in CSS?

As I was reviewing my CSS code, I noticed that the h1 tag is defined like this: h1 { .... } Unlike everything else in my code, which either has an id "#" or a "." class preceding it. This made me wonder why header tags don't require this. Could it b ...

The scrollOverflow feature in fullPage.js is not properly detecting the height of dynamically generated content

I have successfully implemented fullpage.js on my website. Everything is working perfectly with fullpage.js, but I am facing an issue when trying to open a div on click of pagination. Specifically, the browser scroll gets disabled when the div containing a ...

Discovering the differences between input values in HTML when using scripts

I have a code snippet here for an HTML project. The code includes an input field for username and password. I am looking to compare the user's input with a specific value using JavaScript. My question is, what code should be included in the button cli ...

Center element horizontally at a specified breakpoint and below

Can I use Bootstrap 4 utilities to horizontally center an element like a <select> within a col at a specific breakpoint and below? I want to achieve this without using custom CSS. For instance, I want to center a <select> at xs and sm breakpoi ...

Ways to update HTML content generated by Ajax

Having some difficulties modifying the HTML content generated by AJAX. This is the code snippet from the page: @model IEnumerable<WE_SRW_PeerNissen.Models.Reservations> @{ ViewBag.Title = "List"; Layout = "~/Views/Shared/_Layout.cshtml"; } ...

Navigate from the upper left corner to the lower right corner while hovering

Can you animate the movement of an element from the top-left to the bottom-right using CSS transitions like this? #example { width: 40px; height: 40px; background: red; position: absolute; top: 0; left: 0; transition: all 300ms ea ...

What steps should be taken to convert the field into a search icon?

Is it possible to change the field to an icon for mobile devices? See the example below: https://i.sstatic.net/UNZG8.png <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" ...

Changing the color of HTML text based on a variable in Vue JS can be achieved by altering the CSS styles dynamically

I have developed a website that shows values with a set threshold. I now want to change the color of the values when they exceed the threshold, but I am unsure of how to proceed. I want to display consultation.indicateurs.TRS in red when it exceeds the va ...

expanding menu options in a dynamic design

My webpage features a logo alongside a menu: Here's the HTML code: <div id="logomenuwrapper"> <div id="logo"><img src="img/logo_light.jpg"/></div> <div id="menu"> <ul> <li><a href="#">About ...

Angular application causing issues with sticky top navigation bar

Currently, I am working on a web application that features a sticky navigation bar at the top. The unique aspect of this navigation bar is that it includes a brand logo positioned above it. Upon the initial loading of the page, users are greeted by the bra ...

Ways to create sidebar images in a dual-column layout

I am currently working on creating images for my sidebar that have the same width but different heights. I am trying to achieve this without any spaces between the images. To get a better understanding of what I am trying to do, please refer to the follow ...

What are the steps for implementing timezone-js?

I found a project on GitHub that claims to convert one timezone to another. I've been trying to get it to work without success. After downloading and extracting the files, I created an HTML file with the following code: <html xmlns="http://www.w3. ...

Mobile display issue with CSS columns when using the :checked pseudo class

I have embarked on the creation of a portfolio website that relies solely on CSS3 to present a grid and filter out thumbnail images. If you're curious about what I've accomplished so far, feel free to take a look here. To achieve the filtering ...

What is the best way to ensure uniform lengths for both labels and inputs?

Currently, I am in the process of developing a web app using razor pages. My main focus is on the front end (*.cshtml) where I have integrated 4 objects, each consisting of a label and two inputs. My aim is to have all three components appear in line, with ...

Using HTML, jQuery, and JSON with an AJAX call to populate two web tables stacked on top of each other

I am encountering an issue with populating two tables using two searches based on user input in mySQL-JSON-AJAX. When the user enters a search term and clicks the corresponding button, data should populate the respective table. The problem arises when clic ...

Utilizing bootstrap for a responsive design that includes max-height constraints and horizontal

Seeking to modify the appearance of my Angular Template by incorporating Bootstrap and a custom CSS file. <!-- index.html --> <div static-include="partial/example.html"></div> The static-include directive, sourced from Stack Overflow, p ...