Current location: Hot Scripts Forums » General Web Coding » CSS » footer stick and content height 100%


footer stick and content height 100%

Reply
  #1 (permalink)  
Old 06-12-07, 02:26 PM
cowgirlexpressions cowgirlexpressions is offline
New Member
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
footer stick and content height 100%

I just can't seem to get both to work on one page. Heres the code I'm working with:

css Code:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <style type="text/css">
  5. <!--
  6. html,body {
  7.     margin:0;
  8.     padding:0;
  9.     height:100%; /* needed for container min-height */
  10.     background:gray;
  11.    
  12.     font-family:arial,sans-serif;
  13.     font-size:small;
  14.     color:#666;
  15. }
  16.  
  17. div#container {
  18.     position:relative; /* needed for footer positioning*/
  19.     margin:0 auto; /* center, not in IE5 */
  20.     width:100%;
  21.     background:#f0f0f0;
  22.    
  23.     height:auto !important; /* real browsers */
  24.     height:100%; /* IE6: treaded as min-height*/
  25.  
  26.     min-height:100%; /* real browsers */
  27. }
  28.  
  29. div#header {
  30.     background:#ddd url("../csslayout.gif") 98% 10px no-repeat;
  31. }
  32.  
  33. div#content {
  34.     position: relative;
  35.     width: 760px;
  36.     margin: 0 auto;
  37. }
  38.  
  39. div#footer {
  40.     position:absolute;
  41.     width:100%;
  42.     bottom:0; /* stick to bottom */
  43.     background:#ddd;
  44. }
  45.  
  46.  
  47. #col-one {
  48.     float: left;
  49.     width: 380px;
  50.     background-color: #999933;
  51. }
  52. #col-two {
  53.     float: left;
  54.     width: 180px;
  55.     background-color: #6666CC;
  56. }
  57. #col-three {
  58.     float: left;
  59.     width: 180px;
  60.     margin-right: 10px;
  61.     background-color: #FFCC99;
  62. }
  63.  
  64. .clear_both {clear: both;}
  65. -->
  66. </style>
  67. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  68. <title>css test 3</title>
  69. </head>
  70. <body>
  71.  
  72.     <div id="container">
  73.  
  74.         <div id="header">hhhhh    </div>
  75.  
  76.         <div id="content">
  77.           <div id="col-one">    <p>1</p><p>2</p><p>3</p><p>4</p><p>5</p><p>6</p><p>7</p><p>8</p><p>9</p><p>10</p><p>11</p><p>12</p><p>13</p><p>14</p><p>15</p><p>16</p><p>17</p><p>18</p><p>19</p><p>20</p><p>21</p><p>22</p><p>23</p><p>24</p><p>25</p><p>26</p><p>27</p><p>28</p><p>29</p><p>30</p><p>31</p><p>32</p><p>33</p><p>34</p><p>35</p><p>36</p><p>37</p><p>38</p><p>39</p>
  78.  
  79. <p>40</p>
  80. </div>
  81.           <div id="col-two">2</div>
  82.           <div id="col-three">3</div>
  83.           <div class="clear-both"></div>
  84.         </div>
  85.  
  86.         <div id="footer">fffff    </div>
  87.  
  88.     </div>
  89.  
  90. </body>
  91. </html>

Live example: http://www.aceservermanagement.com/j...mgmt/css3.html

Can anyone help me figure out how to get the footer to stick to the bottom with little content and expand with more content? I think it looks ok on IE but not working good in FF (just sticks the footer to window and then extra content expands behind the footer and the content div doesn't stretch). Thanks!!! I appreciate all help!!!

Last edited by Nico; 06-12-07 at 02:30 PM. Reason: Please use [highlight=css] wrappers when posting CSS code.
Reply With Quote
  #2 (permalink)  
Old 06-14-07, 11:00 PM
jfulton's Avatar
jfulton jfulton is offline
Community VIP
 
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
Your link is dead, but it sounds kind of like you want to use 'fixed' position? IE6 can't handle this, but there are lots of work arounds.

http://www.google.com/search?q=IE6+fixed+position
Reply With Quote
  #3 (permalink)  
Old 06-15-07, 03:36 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
This will do what you want:

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
<!--
body {
    background:gray;
    font-family:arial,sans-serif;
    font-size:small;
    color:#666;
    margin:0px;
}
#container {
    width:100%;
    background:#f0f0f0;
    border-collapse:collapse;
}
.td {
    height:575px;
    margin:0;
    vertical-align:top;
}
#header {
    background:#ddd url("../csslayout.gif") 98% 10px no-repeat;
    padding:0px 10px 0px 10px;
}
div#content {
    width: 760px;
    margin:auto;
}
div#footer {
    padding:0px 10px 0px 10px;
    background:#ddd;
}
#col-one {
    float:left;
    width: 360px;
    padding:5px 10px 5px 10px;
    background-color: #999933;
}
#col-two {
    float:left;
    width: 160px;
    padding:5px 10px 5px 10px;
    background-color: #6666CC;
}
#col-three {
    float:left;
    width: 160px;
    padding:5px 10px 5px 10px;
    background-color: #FFCC99;
}
.clear_both {clear: both;}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>css test 3</title>
</head>
<body>
 <table id="container" cellpadding="0" cellspacing="0">
  <tr>
   <td>
    <div id="header">hhhhh</div>
   </td>
  </tr>
  <tr>
   <td class="td">
    <div id="content" >
     <div id="col-one"><p>1</p><p>2</p><p>3</p><p>4</p><p>5</p><p>6</p><p>7</p><p>8</p><p>9</p><p>10</p><p>11</p></div>
     <div id="col-two">2</div>
     <div id="col-three">3</div>
     <div class="clear_both"></div>
    </div>
   </td>
  </tr>
  <tr>
   <td>
    <div id="footer">fffff</div>
   </td>
  </tr>
 </table>
</body>
</html
__________________
Jerry Broughton

Last edited by job0107; 06-15-07 at 04:03 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 02:03 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.