Jump to content

vertical-align: text-bottom not working

- - - - -

  • Please log in to reply
1 reply to this topic

#1
j.lai

j.lai

    Newbie

  • Members
  • PipPip
  • 21 posts
I can't get text-bottom to work on my css. Anyone here know a quick fix or see problems in my css file?

HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Override</title>
<link rel="stylesheet" href="./styles/styles.css">
</head>
<body>
    <header>
    </header>
    <article>
    Under Construction
    </article>
    <footer>
        © 2011, Joey Lai, All rights reserved
    </footer> 
</body>
</html>

CSS:
html{
    padding: 0;
    margin: 0;
    background-color: #000000;
    font-family: Verdana;
    font-size: 10px;
    font-weight: bold;
    color: #666666;
    height: 100%;
    text-align: center;    
}

body{
    background-color: #000000;
    height: 98%;
    width: 99%;
}

header {
    background-color: #000000;
    height:20%;
}

article {
    margin-left: 20%;
    margin-right: 20%;
    height:60%;
    
    -moz-box-shadow: 0px 0px 15px #222222;
    -webkit-box-shadow: 0px 0px 15px #222222;
      box-shadow: 0px 0px 15px #222222;

    -moz-border-radius: 10px;
      -webkit-border-radius: 10px;
      border-radius: 10px;
      
      vertical-align: text-bottom;
}

footer{
    background-color: #000000;
    height:20%;
    position: relative;
    vertical-align: text-bottom;
}



#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
vertical aligning simply doesn't work in block elements. You need to use "tricks" to lower the text. Like make the text have a huge line-height or add an empty span above the text which forces the text down.

<article>
    <span style="position: relative; top: 50%">
    Under Construction
</article>
Both methods have a problem: Line height is a hard coded value, the span with 50% isn't perfectly centered as it does not take the text's size itself into account.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users