Jump to content

CSS border/height problem

- - - - -

  • Please log in to reply
5 replies to this topic

#1
j.lai

j.lai

    Newbie

  • Members
  • PipPip
  • 21 posts
So I'm working on a personal website and am having issues with the height attribute with my css.
Link: Joey Lai - jlai

Essentially, I have my height for my page id (header,content,footer) as 100% but my the body of the page doesn't stretch out to 100% and my footer id is not located on the very bottom of the page.
Help!

HTML:
<!DOCTYPE HTML>
 <html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
        <link rel="stylesheet" type="text/css" href="styles.css" >
        <script type="text/javascript" src="jquery.js"></script>
        
        <script type="text/javascript">
        
        </script>
        
        <title>Joey Lai | HOME</title>
    </head>
    <body>  
        <div id="page">
            <div id="header">
                <ul>
                    <li><a href="http://www.jlai.ca">Home</a></li>
                    <li><a href="http://www.jlai.ca/ep3blog.html">EP3</a></li>
                    <li><a href="http://www.jlai.ca/about.html">About</a></li>
                    <li><a href="http://www.jlai.ca/contact.html">Contact</a></li>
                    
                </ul>                        
            </div>
            
            <div id="body">
                TEST 
            </div>            
            
            <div id="footer">
                © All Rights Reserved By Joey Lai
            </div>        
        </div>
    </body>  
</html>

CSS:

body
{
    background-color: #FFFFFF;
    font-family: verdana;
    font-size: 70%;
    color: #FFFFFF;
    width: 100%;
    height: 100%;
    
}

* 
{
margin: 0;
padding: 0;
}

a:link
{
    color: #666666;
    text-decoration: none;
    text-transform: uppercase;
}
a:visited 
{
    color: #666666;
    text-decoration: none;
    text-transform: uppercase;
}
a:active 
{
    color: #666666;
    text-decoration: none;
    text-transform: uppercase;
}
a:hover 
{
    color: #FFFFFF;
    text-decoration: none;
    text-transform: uppercase;
}

div#page
{
    background-color: #333333;
    height:    100%;
    margin-left: 10%;
    margin-right: 10%;
    border-style: solid;
    border-width: 1px;
}

div#header
{
    background-color: #000000;
    font-size: 120%;
    height: 50px;
}
    ul
    {
        list-style-type: none;
    }
        li
        {
            float: left;
            padding: 10px;
        }

div#body
{
    
}
        
div#footer
{
    color:#333333;
    background-color: #000000;
    bottom:0;
    height: 35px;
    text-align: center;
}


#2
oldhendra

oldhendra

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
Probably this would solve ??
html{
  height: 100%;
}


#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Your body has no height, so it will take up only a predetermined space until you add a style such as:
body {
  height: 100%;
}
That worked for me (save for a little issue with the body breaking which can be fixed)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
j.lai

j.lai

    Newbie

  • Members
  • PipPip
  • 21 posts
ooo! yeah I totally forgot about the html 100%. I already had the body 100%.

Now is there a way to move the footer to the bottom of the page#div without making it bottom:0 with position:absolute?

#5
oldhendra

oldhendra

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
Try position: relative for #footer ?
For it to always follow #page height, set its top to 100%.
After that, you could fine-adjust it using margin-top, say margin-top: -95px.
div#footer{
[COLOR=red]  position: relative;
  top: 100%;
  margin-top: -95px;
[/COLOR]  color:#333333;
  background-color: #000000;
  bottom:0;
  height: 35px;
  text-align: center;
}
Hei J.Lai... do you know that you could go on playing with CSS
like this directly using DOM Inspector. I think every modern browsers
have it built-in.;)

Ups, one more thing... You have to have #page set its min-height, else all divs will be hidden by #footer:
div#page{   min-height: 100px; }
Hendra

#6
j.lai

j.lai

    Newbie

  • Members
  • PipPip
  • 21 posts
Ooo, Ok thanks! I'll check out DOM inspector




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users