3

To start off I'm relatively new to CSS, Bootstrap and HTML. I want to position a responsive element at the bottom of the screen. So I have this code which makes it behave responsively:

<div class="col-sm-12">
    test
</div>

But how do I get it to stick to the bottom of the page? I already tried ID/ Class selectors with an absolute position. It moved the element to the bottom, but it wasn't responsive anymore.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
SkyboyKP
  • 41
  • 1
  • 1
  • 2

3 Answers3

4

One solution might be to wrap the desired element in another div, then target the wrapper element to fix it to the bottom of your screen. Your markup could look like:

<div class="fixed-container">
    <div class="col-sm-12"><!--your content here--></div>
</div><!--end .fixed-container-->

And you styles could look like:

.fixed-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
}

This would affix the .fixed-container element to the bottom left of the viewport, and would set the width to 100% of the viewport. The layout-specific rules applied to .col-sm-12 would remain intact.

Brad Frost
  • 401
  • 1
  • 4
  • 9
3
<div id="my-element" class="col-sm-12">
    test
</div>

#my-element {
    position: fixed;
    bottom: 0;
}
Destination Designs
  • 683
  • 1
  • 5
  • 17
0

Here is a simple solution to your problem.

Make sure your elements are in a wrapping div. Since you are using Bootstrap, use:

<div class="container-fluid">

Inside this container place your elements/sections including your footer:

<footer class="col-md-12">

Your footer should have the following CSS.

footer {
       position: absolute;
       bottom: 0;
       height: 100px /* Height of your footer */
       width: 100%;
   }

Here is a fiddle. You can see the footer is at the bottom of the container which has a black border.

http://jsfiddle.net/gward90/ehf2wm83/

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
gwar9
  • 1,082
  • 1
  • 11
  • 28