Making page content not fixed

George Irimiciuc

I have http://jsfiddle.net/EN8CX/

What I want to do first is set the default page to have the footer at the bottom. Is there a better way than modifying the content's height?

#content {
min-height:200px;}

I'm asking this because I can't set a fixed height for the content. Later on I will add a search function which might have to display more results than the page, so I'll need a scroll bar. That will push the footer down, of course. How can I do it?

josephnvu

I myself was in this same predicament and took me a while to figure this out. But I think I got it! So you would have to modify your HTML a little bit. You need to take out the footer and place it in the same level as the container. So it'll look something like this:

<body>
  <div id="container">
    ...
  </div>
  <div id="footer">
    ...
  </div>
</body>

In the CSS, make the "container" with the minimum height of the whole viewport using "vh" units. Then take the footer height and use it to pad the bottom of the content. Take the footer and reverse the margin upward to make it peak through using again the height of the footer:

#container {
  ...
  min-height: 100vh;
}

#content {
  ...
  padding-bottom: 70px; // if footer height = 70px;
} 

#footer {
  ...
  margin-top: -70px;
}           

I have a fiddle running here: http://jsfiddle.net/EN8CX/5/ . I also added a button to grow the content so you can see the footer get pushed down.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Making content responsible between fixed divs

From Dev

Making the web page fixed and un-zoomable

From Dev

fixed page, content scrolling behind header

From Dev

Fixed Header and Footer not allowing page content to scroll?

From Dev

Making an element fixed on scroll, when its not at the top of the page

From Dev

How to make web page content scroll over a fixed header?

From Dev

Bootstrap navbar-fixed-top hiding page content

From Dev

Fixed navigation menu content not scrolling with page horizontally, when zoomed in

From Dev

How to overlay a fixed header while scrolling page content?

From Dev

Page Layout with Fixed HTML Header and Footer, with Flexible content

From Dev

How to make web page content scroll over a fixed header?

From Dev

jQuery Mobile 1.4.3 fixed toolbar and page content issue

From Dev

Content "slides" in under fixed header on page load broken on Safari

From Dev

Why printed HTML content in fixed page size is sometimes wrong

From Dev

Making a form fixed

From Dev

Bootstrap Affix fixed header after 100px making content jump

From Dev

Making Recyclerview Fixed Height and Scrollable

From Dev

Making a fixed header appear persistent

From Dev

Making StaggeredGridLayout wrap content

From Dev

Making a container to fill it with content?

From Dev

Making header the size of content

From Dev

How to auto update the content after fixed intervals in windows phone 8 page that retrieve data from Json

From Dev

Navbar overlaps content in fixed-navigation bootstrap page when clicking links

From Dev

How can fixed element push content down the page using CSS only?

From Dev

How to get 100% height of page content when using a MDL fixed header in Chrome?

From Dev

Keeping the page vertically fixed on an element, when lots of content is revealed above (so causing scroll)

From Dev

Add fixed footer inside content that's already bounded by page-level header and footer

From Dev

Fixed block with big content

From Dev

Fixed sidebar, scrollable content

Related Related

  1. 1

    Making content responsible between fixed divs

  2. 2

    Making the web page fixed and un-zoomable

  3. 3

    fixed page, content scrolling behind header

  4. 4

    Fixed Header and Footer not allowing page content to scroll?

  5. 5

    Making an element fixed on scroll, when its not at the top of the page

  6. 6

    How to make web page content scroll over a fixed header?

  7. 7

    Bootstrap navbar-fixed-top hiding page content

  8. 8

    Fixed navigation menu content not scrolling with page horizontally, when zoomed in

  9. 9

    How to overlay a fixed header while scrolling page content?

  10. 10

    Page Layout with Fixed HTML Header and Footer, with Flexible content

  11. 11

    How to make web page content scroll over a fixed header?

  12. 12

    jQuery Mobile 1.4.3 fixed toolbar and page content issue

  13. 13

    Content "slides" in under fixed header on page load broken on Safari

  14. 14

    Why printed HTML content in fixed page size is sometimes wrong

  15. 15

    Making a form fixed

  16. 16

    Bootstrap Affix fixed header after 100px making content jump

  17. 17

    Making Recyclerview Fixed Height and Scrollable

  18. 18

    Making a fixed header appear persistent

  19. 19

    Making StaggeredGridLayout wrap content

  20. 20

    Making a container to fill it with content?

  21. 21

    Making header the size of content

  22. 22

    How to auto update the content after fixed intervals in windows phone 8 page that retrieve data from Json

  23. 23

    Navbar overlaps content in fixed-navigation bootstrap page when clicking links

  24. 24

    How can fixed element push content down the page using CSS only?

  25. 25

    How to get 100% height of page content when using a MDL fixed header in Chrome?

  26. 26

    Keeping the page vertically fixed on an element, when lots of content is revealed above (so causing scroll)

  27. 27

    Add fixed footer inside content that's already bounded by page-level header and footer

  28. 28

    Fixed block with big content

  29. 29

    Fixed sidebar, scrollable content

HotTag

Archive