mears11
asked on
Quick question about vertical-align: inherit
I have the following in the body of a page:
<div id="centerpage">
<div id="header">
</div>
<div id="subhcontainer">
<div id="stripefill"></div>
<div id="merge"></div>
<div id="login">
<div class="centerwhite">Userna me: <input class="tb" type="text" name="uname" size="10" maxlength="15"> Password: <input class="tb" type="password" name="pass" size="10" maxlength="15">   ; <input class="buttons" type="submit" value="Login"></div>
</div>
</div>
I'm going to post the relevant portion of my stylesheet below, but basically I'm wondering why my text boxes aren't centered vertically withing the #login div. I can get them to center by setting their vertical-align property to middle, but I'm trying to get it to work by using vertical-align: inherit; I've tried setting both the #centerwhite and #login vertical-align properties to middle in hopes that the text boxes would center, but for some reason the inherit isn't working and instead they are aligned with the top. Here is the relevant CSS:
html, body{
background-image: url("../images/bg.gif");
text-align: center;
}
div#centerpage
{
margin-left: auto;
margin-right: auto;
width: 750;
}
div#header{
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
/*ie 5x hack 750 + 2*1*/
width: 752px;
height: 77px;
background-image: url("../images/top.jpg");
voice-family: "\"}\"";
voice-family:inherit;
width: 750px;
height: 75px;
}
html>body div#header {
width: 750px;
height: 75px;
}
div#subhcontainer
{
position: relative;
width: 752px;
height: 27px;
border-bottom: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
voice-family: "\"}\"";
voice-family: inherit;
width: 750px;
height: 26px;
}
div#stripefill
{
position: absolute;
left: 0px;
background-image: url("../images/pint.gif");
vertical-align: top;
width: 370px;
height: 26px;
}
div#merge
{
position: absolute;
left: 370px;
background-image: url("../images/merge.gif") ;
width: 50px;
height: 26px;
}
div#login
{
position: absolute;
left: 420px;
vertical-align: middle;
background-color:#000000;
width: 330px;
height: 26px;
}
.centerwhite{
font-family: Arial, sans-serif;
color: #FFFFFF;
font-size: 10px;
vertical-align: middle;
}
input.tb{
vertical-align:inherit;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #EDEDED
}
input.buttons {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #333333;
height:auto;
top: 5px;
bottom:5px;
color: #FFFFFF;
margin-right: 6px;
}
<div id="centerpage">
<div id="header">
</div>
<div id="subhcontainer">
<div id="stripefill"></div>
<div id="merge"></div>
<div id="login">
<div class="centerwhite">Userna
</div>
</div>
I'm going to post the relevant portion of my stylesheet below, but basically I'm wondering why my text boxes aren't centered vertically withing the #login div. I can get them to center by setting their vertical-align property to middle, but I'm trying to get it to work by using vertical-align: inherit; I've tried setting both the #centerwhite and #login vertical-align properties to middle in hopes that the text boxes would center, but for some reason the inherit isn't working and instead they are aligned with the top. Here is the relevant CSS:
html, body{
background-image: url("../images/bg.gif");
text-align: center;
}
div#centerpage
{
margin-left: auto;
margin-right: auto;
width: 750;
}
div#header{
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
/*ie 5x hack 750 + 2*1*/
width: 752px;
height: 77px;
background-image: url("../images/top.jpg");
voice-family: "\"}\"";
voice-family:inherit;
width: 750px;
height: 75px;
}
html>body div#header {
width: 750px;
height: 75px;
}
div#subhcontainer
{
position: relative;
width: 752px;
height: 27px;
border-bottom: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
voice-family: "\"}\"";
voice-family: inherit;
width: 750px;
height: 26px;
}
div#stripefill
{
position: absolute;
left: 0px;
background-image: url("../images/pint.gif");
vertical-align: top;
width: 370px;
height: 26px;
}
div#merge
{
position: absolute;
left: 370px;
background-image: url("../images/merge.gif")
width: 50px;
height: 26px;
}
div#login
{
position: absolute;
left: 420px;
vertical-align: middle;
background-color:#000000;
width: 330px;
height: 26px;
}
.centerwhite{
font-family: Arial, sans-serif;
color: #FFFFFF;
font-size: 10px;
vertical-align: middle;
}
input.tb{
vertical-align:inherit;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #EDEDED
}
input.buttons {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #333333;
height:auto;
top: 5px;
bottom:5px;
color: #FFFFFF;
margin-right: 6px;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Some good and correct information here, there is just one thing that needs to be added. Even if it was correctly applied it would only work for a small percentage of users because inherit is not support for vertical-align by IE.
Cd&
Cd&
ASKER
Thanks for the clarrification. Also, thanks to seanpowell for finding that missing "px" and to COBOLdinosaur for the extra tip.
Also, you need to set a unit on your centerpage width for Mozilla. The following assumes standards mode rendering:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
html, body
{
background-image: url("../images/bg.gif");
text-align: center;
}
div#centerpage
{
margin: 0 auto;
width: 750px;
}
div#header
{
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
/*ie 5x hack 750 + 2*1*/
width: 752px;
height: 77px;
background-image: url("../images/top.jpg");
voice-family: "\"}\"";
voice-family:inherit;
width: 750px;
height: 75px;
}
html>body div#header
{
width: 750px;
height: 75px;
}
div#subhcontainer
{
position: relative;
width: 752px;
height: 27px;
border-bottom: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
voice-family: "\"}\"";
voice-family: inherit;
width: 750px;
height: 26px;
}
div#stripefill
{
position: absolute;
left: 0;
background-image: url("../images/pint.gif");
width: 370px;
height: 26px;
}
div#merge
{
position: absolute;
left: 370px;
background-image: url("../images/merge.gif")
width: 50px;
height: 26px;
}
div#login
{
position: absolute;
left: 420px;
background-color:#000;
width: 330px;
height: 26px;
}
.centerwhite
{
font-family: Arial, sans-serif;
color: #FFF;
font-size: 10px;
margin:3px 0 0 0;
}
input.tb
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #EDEDED;
margin:0 10px 0 3px;
}
input.buttons
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #333333;
line-height:11px;
color: #FFFFFF;
padding:0;
}
</style>
</head>
<body>
<div id="centerpage">
<div id="header"></div>
<div id="subhcontainer">
<div id="stripefill"></div>
<div id="merge"></div>
<div id="login">
<div class="centerwhite">
Username: <input class="tb" type="text" name="uname" size="10" maxlength="15">
Password: <input class="tb" type="password" name="pass" size="10" maxlength="15">
<input class="buttons" type="submit" value="Login">
</div>
</div>
</div>
</div>
</body>
</html>