HOT
22bulbjungle
No Result
View All Result
22bulbjungle
No Result
View All Result
Home Web Development CSS

How To Align the Content of a Div to the Bottom with CSS[CODE]

in CSS
Reading Time: 2 mins read
446 28
0
652
SHARES
3k
VIEWS
Share on FacebookShare on Twitter

(Video transcription)

Creating the Markup

Here on the HTML document.
Let’s create the parent div element with a class of “container.”

RelatedPosts

How To Create a Beating Heart Shape Animation Using CSS

How To Transition a Height of Zero to a Height of Auto?

How To Apply CSS to Half of a Character

Inside this container will be another two div elements.

For the first one, let’s add a class of main content.

The second one will be the bottom content.

I’m going to add some dummy content to both of them.

As you notice, we wrap our content with the div elements. It is important so we can move them together rather than selecting each inline element.

Adding the CSS

For the container, add a maximum width. A margin, padding, and border so we could see its actual dimension for demo purposes only.

The same with the bottom content.

Now, we want to pull this bottom content div to the bottom.
So we need to add an absolute position CSS to this div element. But before that, make sure to add a “position relative” CSS to the parent element. So it doesn’t go outside our div, which is the “container.”

Positioning using CSS

Then, we can add position absolute. Bottom zero, Left zero. So there’s no space left.
You could also align this to the right with “right zero.” Remove the left zero.
Or align it to the bottom center by adding margin auto with left zero.

Full HTML and CSS Code

<div class="container">
        
        <div class="main_content">
            <h1 class="large_title">Lorem Ipsum Dolor Sit Amet,Consectetur Adipiscing Elit</h1>
        </div>
        
        <div class="bottom_content">
            <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. sint occaecat cupidatat non proident.</p>
        </div>
    
 </div>
*{
    box-sizing: border-box;
}
body{
    margin: 0;
    font-family: 'Open sans', sans-serif;
    font-size: 18px;
    background-color: #e9e9f5;
}
.large_title{
    font-size: 4em;
    color: #06004b
}
p{
    font-size: 1.5em
}
.container{
    max-width: 1200px;
    margin: 40px auto;
    padding: 15px;
    border: 15px solid #66e3f3;
    border-radius: 5px;
    min-height: 90vh;
    
    position:relative
}
.bottom_content{
    background: #d0ccff;
    padding: 15px;
    max-width: 500px;
    border: 15px solid #ada6ff;
    border-radius: 5px;
    position:absolute;
    
    bottom: 0;
    right: 0;
    left: 0;
    margin: auto;
    
}

 

Tags: css beginnercss positioning
Share261Tweet163Share65

Related Posts

How To Create a Beating Heart Shape Animation Using CSS
CSS

How To Create a Beating Heart Shape Animation Using CSS

by 22bulbjungle
December 28, 2022
0

Create the HTML structure Create the HTML structure for the heart shape. We'll use a div element with the class "heart": <div...

Read more
How to transition a height of zero to a height of Auto

How To Transition a Height of Zero to a Height of Auto?

December 23, 2022
How To Apply CSS to Half of a Character

How To Apply CSS to Half of a Character

December 23, 2022
How To Set Cellpadding and Cellspacing Using CSS

How To Set Cellpadding and Cellspacing Using CSS

December 22, 2022
Electronics, Smartphone, Computer & Tablet Repair Kit
How To Create a Beating Heart Shape Animation Using CSS

How To Create a Beating Heart Shape Animation Using CSS

December 28, 2022
How to transition a height of zero to a height of Auto

How To Transition a Height of Zero to a Height of Auto?

December 23, 2022
How To Apply CSS to Half of a Character

How To Apply CSS to Half of a Character

December 23, 2022
How To Set Cellpadding and Cellspacing Using CSS

How To Set Cellpadding and Cellspacing Using CSS

December 22, 2022
How To Prevent or Disable Copy and Paste in an Input Field

How To Prevent or Disable Copy and Paste in an Input Field

December 21, 2022
How To Turn Image Into Vintage With CSS

How To Turn Image Into Vintage With CSS

December 21, 2022

Free Do it yourself tutorials on CSS, HTML, Photoshop, Wordpress, and Woocommerce to help you learn web development and graphic design.

Follow Us

Affiliate Disclosure: 22bulbjungle is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.

Recent Tutorials

How To Create a Beating Heart Shape Animation Using CSS

How To Create a Beating Heart Shape Animation Using CSS

December 28, 2022
How to transition a height of zero to a height of Auto

How To Transition a Height of Zero to a Height of Auto?

December 23, 2022

Categories

  • CSS
  • Duda Builder
  • Ecommerce
  • Elementor
  • Graphic Design
  • htaccess
  • Javascript
  • jQuery
  • PC Tips
  • Photoshop
  • PHP
  • Responsive design
  • Shopify
  • Video
  • Web Design
  • Web Development
  • Webdev Tips
  • Woocommerce
  • Wordpress
  • Home
  • Blog
  • Web Development
  • Graphic Design

© 2022 22BulbJungle.

No Result
View All Result
  • Home
  • Blog
  • Web Development
    • CSS
    • Javascript
    • WordPress
  • Graphic Design
    • Photoshop

© 2022 22BulbJungle.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.