Languages
[Edit]
EN

CSS - bottom sticky position for div element

10 points
Created by:
Giles-Whittaker
589

In this short article we would like to show how to use sticky bottom positioning with pure CSS.

Bottom sticky position for div element using CSS.
Bottom sticky position for div element using CSS.

Note: to see better description how sticky works and how to use top positioning read this article.

Simple example:

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>
    
    body {
    	max-height: 300px;
    }

    div.content {
    	border: 1px solid orange;
      	height: 1000px;
    }
    
    div.footer {
        position: -webkit-sticky;  /* <----- required (for WebKit) */
        position: sticky;  /* <------------- required              */
        bottom: 10px;  /* <----------------- required              */
		border: 1px solid red;
      	background: silver;
    }

  </style>
</head>
<body>
  <div>
    <div class="content">
      Some text here...<br />
      Some text here...<br />
      Some text here...<br />
      Some text here...<br />
    </div>
    <div class="footer">Footer 1</div>
  </div>
  <p>Some text here...</p>
  <p>Some text here...</p>
  <p>Some text here...</p>
</body>
</html>

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

CSS

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join