RoboPHP
RoboPHP

Reputation: 420

Footer moves along when scrolling - HTML &CSS

I have footer like shown below in the code. When user is scrolling , the footer moves along. how do stop the footer from going along with the scrolling ? The footer should stay at the bottom of the page even when scrolling .

At the moment, it scrolls when i move up and down. But it should have to stick at bottom

How can i achieve this ?

PS: Beginner with CSS and pardon my english HTML

<div class="content" id="content">
        <div class="container">
            <div id="elliot-for-water" class="row elliot-for-water">
                <div class="col-md-8 col-sm-8 ">
                    <h2 class="title">Terms of Service</h2>

                    </div>
                </div>
            </div>

        </div>
        <!-- end row -->
    </div><!-- end container -->

<footer class="footer-distributed">

        <div class="footer-right">

            <a href="#"><i class="fa fa-facebook"></i></a>
            <a href="#"><i class="fa fa-twitter"></i></a>             
        </div>

        <div class="footer-left">

            <p class="footer-links">
                <a class="link-1" href="#">Home</a>
                <a href="#">Faq</a>   
                <a href="#">Contact</a>
            </p>   
            <p>Company Name &copy; 2015</p>
        </div>

    </footer>

CSS

.footer-distributed {
  background-color: #292c2f;
  box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  font: normal 16px sans-serif;
  padding: 45px 50px;
}

.footer-distributed .footer-left p {
  color: #8f9296;
  font-size: 14px;
  margin: 0;
}
/* Footer links */

.footer-distributed p.footer-links {
  font-size: 18px;
  font-weight: bold;
  color: #ffffff;
  margin: 0 0 10px;
  padding: 0;
  transition: ease .25s;
}

.footer-distributed p.footer-links a {
  display: inline-block;
  line-height: 1.8;
  text-decoration: none;
  color: inherit;
  transition: ease .25s;
}

.footer-distributed .footer-links a:before {
  content: "·";
  font-size: 20px;
  left: 0;
  color: #fff;
  display: inline-block;
  padding-right: 5px;
}

.footer-distributed .footer-links .link-1:before {
  content: none;
}

.footer-distributed .footer-right {
  float: right;
  margin-top: 6px;
  max-width: 180px;
}

.footer-distributed .footer-right a {
  display: inline-block;
  width: 35px;
  height: 35px;
  background-color: #33383b;
  border-radius: 2px;
  font-size: 20px;
  color: #ffffff;
  text-align: center;
  line-height: 35px;
  margin-left: 3px;
  transition:all .25s;
}

.footer-distributed .footer-right a:hover{transform:scale(1.1); -webkit-transform:scale(1.1);}

.footer-distributed p.footer-links a:hover{text-decoration:underline;}

/* Media Queries */

@media (max-width: 600px) {
  .footer-distributed .footer-left, .footer-distributed .footer-right {
    text-align: center;
  }
  .footer-distributed .footer-right {
    float: none;
    margin: 0 auto 20px;
  }
  .footer-distributed .footer-left p.footer-links {
    line-height: 1.8;
  }
}

Upvotes: 1

Views: 133

Answers (2)

Omolewa Stephen
Omolewa Stephen

Reputation: 421

For your footer:

#footer {
    position: fixed;
    height: 50px;
    bottom: 0px;
    left: 0px;
    right: 0px;
    margin-bottom: 0px;
}

For your body:

body {
    margin-bottom:50px;
}

Check here codesandbox-link

Upvotes: 0

NIKHIL NEDIYODATH
NIKHIL NEDIYODATH

Reputation: 2932

You can apply the following style to your footer to keep it in a fixed position

<style>
footer {
    position: fixed;
    bottom:0px;
}
</style>

Upvotes: 2

Related Questions