EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

CSS @bottom

Home » Software Development » Software Development Tutorials » CSS Tutorial » CSS @bottom

CSS @bottom

Introduction to CSS @bottom

CSS Bottom is defined as the bottom property specifies the vertical position of an element added with the position property. It gives the offset at the bottom edge of the reference elements box in any browser windows, which is an element that is altered from the bottom of the viewport. The bottom property does not affect the static position. In this topic, we are going to learn about CSS @bottom.

Syntax and Parameters

The general Syntax is given as:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

.container
{
bottom: value;
}
Value: length |percentage |auto | initial;

Parameters

The parameters define as :

  • length: The value specified in px or em either negative or positive values
  • percentage: This value specifies the percentage of the box element height.
  • auto: It’s a default value. and treat height as a value.
  • inherit: This value inherits its parent container value.

sample example

bottom: 4px         /* length */
bottom: 1.4em
bottom: 20%         / *<percentages */
bottom: auto
bottom: inherit

The element moves away from a given side when a value is assigned positive and negative value moves towards it. For instance, if bottom: -15 px; This sets the paragraph below the bottom edge of a window.

How @bottom works in CSS?

Here Let’s see how this property works by seeing their effect on different positioned elements.

Relatively positioned: When the position is set to this property the bottom adds a respective offset to the bottom edge which moves its position from original form to its top. Generally, a top property overrides the bottom property in many aspects. An offset based on the bottom values is applied to the element itself.

Popular Course in this category
CSS Training (9 Courses, 9+ Projects)9 Online Courses | 9 Hands-on Projects | 61+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,090 ratings)
Course Price

View Course

Related Courses
Bootstrap Training (2 Courses, 6+ Projects)jQuery Training (8 Courses, 5 Projects)

Absolute position: With this, the element would move upwards concerning the nearest parent. To understand this example is given in the next section.

Static: This is the default value and does not affect any element.

In the case of JavaScript, the Syntax given as follows

Object.style.bottom=”50px”;

Examples

Let’s see how this bottom property works in action with an example:

Example #1

Let’s take an example – effect on the absolute property.

Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of CSS bottom property</title>
<style>
p {
width: 220px;
position: absolute;
bottom: 100px;
padding: 22px;
font: bold 16px algerian;
background: LightBlue;
}
h1
{
color : red;
}
</style>
</head>
<body>
<h1> Example of Bottom property -CSS </h1>
<p>Bottom Property at the bottom margin of the Page</p>
</body>
</html>

Output:

CSS @bottom output 1

Example #1a

With the same pattern, we can place an image in the bottom property.

Code:

<html>
<head>
<style type="text/css">
img
{
position:absolute;
bottom:0px
}
h1
{
color: aqua;
}
</style>
</head>
<body>
<h1>Bottom property on Image </h1>
<img src="diary.jpg" width="90" height="80" />
<p>This is an image.</p>
</body>
</html>

Output:

CSS @bottom output 1.2

Example #2

With a position set to relative and using value ‘Length’.

Code:

<!DOCTYPE html>
<html>
<head>
<style>
div.square {
width: 12rem;
height: 12rem;
display: flex;
justify-content: center;
align-items: center;
background-color: solid purple;
position: relative;
bottom: 60px;
}
div.outborder {
display: inline-block;
border: 3px dashed yellow;
margin: 30px 0 1 30px;
}
</style>
</head>
<body>
<h1>A Bottom Property with Positioned elements</h1>
<div class="outborder">
<div class="square">
<pre> relative position </pre> </div>
</div>
</body>
</html>

When a bottom is set on the element with respect to the relative position, the element moves up from the original placement of the document. Assigning bottom to 60px it shift its positions to the top.

Output:

CSS @bottom output 2

Example #3

Setting a default value for the bottom property.

Code:

<html>
<head>
<title> Bottom - Demo </title>
</head>
<body>
<h1 style="color:purple;">Welcome to the Home Page</h1>
<p style="position: fixed; bottom: auto; justify-content: center;
align-items: center; border: 3px dashed yellow;
margin: 30px 0 1 30px;">
This property makes a paragraph content to be auto adjusted from the margin of bottom page.
</p>
</body>
</html>

Output:

CSS @bottom output 3

Example #4

Code:

<!DOCTYPE html>
<html>
<head>
<title>
CSS bottom Property- Demo
</title>
<style>
div{
position: relative;
width: 100px;
height: 110px;
font-size: 20px;
}
#length {
bottom: -100px;
border: 4px solid purple;
}
#emvalue {
bottom: -20em;
border: 4px solid aqua;
}
#autovalue {
bottom: auto;
border: 4px solid darkviolet;
}
#initdefault{
bottom: initial;
border: 7px solid yellow ;
}
h1{
text-align: center;
}
</style>
</head>
<body>
<h1> Example of the bottom Property </h1>
<div id = "length"> bottom: -100px; </div>
<div id = "emvalue"> bottom: -15em; </div>
<div id = "autovalue"> bottom: auto; </div>
<div id = "initdefault"> bottom: initial; </div>
</body>
</html>

Output:

output 4

Example #5

An example demonstrating bottom property on the Static element.

Code:

<html>
<style>
.main-b {
position: static;
right: 20px;
bottom: -20px;
background-color: blue;
padding: 12px;
}
.derived-b {
padding: 12px;
background-color: Orange;
}
</style>
<body>
<div class="parent-b">
<div class="derived-b">
inner element.
</div>
<div class="main-b">
the main element.
</div>
<div class="derived-b">
SUb-element.
</div>
</div>
</body>
<html>

The code above shows static in which if I had happened to change the value of the right , bottom we could see the unchanged output.

Output:

output 5

Example #6

Code:

<!DOCTYPE html>
<html>
<head>
<title>CSS bottom property with bottom</title>
<style>
div {
font-family: Algeria;
font-size: 22px;
}
.A {
border: 12px solid yellow;
position: relative;
}
div.abc, div.xyz {
background-color: red;
border: 2px solid orange;
}
div.abc {
bottom: 15%;
position: absolute;
}
div.xyz {
bottom: 0;
position: absolute;
}
</style>
</head>
<body>
<h1><code><b>15% bottom</b></code></h1>
<div class="A">Denmark, country which is located in western Europe with small population and territory which connects North Sea to Baltic Sea. Denmark experiences frequent freeze and snow falls. <div class="abc">This element absolutely positioned.</div>
</div>
<br />
<h1><code><b>0 bottom</b></code></h1>
<div class="A">Denmark, country which is located in western Europe with small population and territory which connects North Sea to Baltic Sea. Denmark experiences frequent freeze and snow falls. <div class="xyz">This element absolutely positioned.</div>
</div>
</body>
</html>

Here we could see a percentage value calculated on the bottom with absolute position. This code has two <div> class with absolute positioning and the bottom value of Abc class is 15 and xyz is zero. In the output, we can see the difference where ‘0’ bottom value places the text on the bottom edge, whereas the 15 % value places the bottom text quite up.

Output:

output 6

Conclusion

Therefore, coming to the end, this CSS article explains how to use the Property called Bottom with their working and examples. Here we have seen a well-organized explanation with a lot of examples of how to use this in CSS. This property along with attributes like left-right helps to display exact positions.

Recommended Articles

This is a guide to CSS @bottom. Here we discuss How @bottom works in CSS along with programming examples. You may also look at the following articles to learn more –

  1. CSS @keyframes
  2. CSS Typography
  3. CSS nowrap
  4. CSS Formatter

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
CSS Tutorial
  • CSS
    • Introduction To CSS
    • What is CSS?
    • Uses Of CSS
    • Advantages of CSS
    • Career In CSS
    • CSS Commands
    • Is Css Case Sensitive
    • CSS object-fit
    • Types of CSS Selectors
    • CSS Radio Button
    • CSS Attribute Selector
    • CSS Selector nth Child
    • CSS Parent Selector
    • CSS Child Selector
    • CSS Not Selector
    • CSS Descendant Selector
    • CSS Inline Style
    • Checkbox CSS
    • CSS Font Properties
    • CSS font-variant
    • CSS Pagination
    • CSS Table Styling
    • CSS Table Cell Padding
    • CSS Padding Color
    • CSS Text Formatting
    • CSS for Text-Shadow
    • CSS text-stroke
    • CSS text-indent
    • CSS Rotate Text
    • CSS Text Color
    • CSS Center Div
    • CSS Arrow
    • CSS Arrow Down
    • CSS offset
    • CSS Cursor
    • CSS Layout
    • CSS Grid Layout
    • Button in CSS
    • CSS Button Border
    • text-align in CSS
    • CSS Horizontal Align
    • CSS Position
    • CSS Box Sizing
    • CSS box-shadow
    • CSS Text Underline
    • CSS Text Outline
    • CSS Blinking Text
    • Text Decoration CSS
    • CSS Vertical Align
    • CSS Word Wrap
    • CSS Padding
    • CSS Font Color
    • CSS Color Generator
    • CSS Margin Right
    • CSS Margin Color
    • CSS Color Codes
    • CSS Color Transparent
    • CSS Color Chart
    • CSS Link Color
    • CSS z-index
    • CSS Curved Border
    • CSS Border Left
    • CSS left
    • CSS Gradient Generator
    • Radial Gradient in CSS
    • CSS Shape Generator
    • CSS Triangle Generator
    • CSS background-color
    • CSS Background Image
    • CSS background-clip
    • CSS background-blend-mode
    • CSS Drop Shadow
    • CSS line height
    • CSS line break
    • Sticky Footer CSS
    • CSS Header Design
    • CSS Border Style
    • CSS Border Generator
    • Sticky Sidebar CSS
    • CSS Transparent Border
    • CSS Border Radius
    • CSS translate
    • CSS transform
    • CSS 3D Transforms
    • CSS Text Transform
    • CSS Transition Effects
    • CSS Animation Transition
    • Negative Margin CSS
    • CSS Navigation Bar
    • CSS Overflow
    • CSS overflow-wrap
    • CSS Lists
    • CSS Order
    • CSS Box Model
    • CSS Inner Border
    • Menu Icon CSS
    • CSS Multiple Borders
    • Opacity in CSS
    • CSS Float Right
    • CSS Clear Float
    • CSS clip
    • CSS disabled
    • CSS Border Padding
    • Border Images in CSS
    • CSS Visibility
    • CSS Validator
    • CSS Clearfix
    • CSS Counter
    • CSS Letter Spacing
    • CSS root
    • CSS zoom
    • CSS calc()
    • CSS.supports()
    • CSS Loader
    • Media Query CSS
    • CSS @keyframes
    • CSS @bottom
    • CSS page-break-after Property
    • CSS page-break
    • CSS Position Fixed
    • CSS skew()
    • CSS Row
    • CSS Masking
    • CSS Scrollbar
    • CSS Overlay
    • CSS Important
    • CSS Cursor Hand
    • CSS Inherit
    • CSS Position Relative
    • CSS Compressor
    • CSS tricks
    • CSS Outline Property
    • CSS Flexbox Properties
    • CSS flex-direction
    • CSS content property
    • CSS Typography
    • CSS Formatter
    • CSS nowrap
    • CSS Column
    • GridView CSS
    • CSS Viewport
    • CSS Minify
    • CSS Combinators
    • CSS in React
    • CSS Matrix 
    • CSS Pseudo Elements
    • CSS Pseudo Classes
    • CSS Pointer Events
    • CSS Resize
    • CSS Inheritance
    • CSS Interview Questions
    • Cheat Sheet CSS
  • CSS3
    • What is CSS3?
    • CSS3 Interview Questions
    • Cheat sheet CSS3
  • sass
    • How to Install SASS
    • SASS Interview Questions
    • What is Sass
    • SASS Comments
    • Sass Variables
    • SASS Import
    • SASS if else
    • SASS Nesting
    • SASS @each
    • SASS @at-root
    • SASS @extend
    • SASS @media
    • SASS @for
    • SASS Map
    • SASS Selectors
    • SASS Color Functions
    • SASS Mixins

Related Courses

CSS Training Course

Bootstrap Training Course

JQuery Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - CSS Training Course Learn More