ice78991
Programmer
- Nov 20, 2006
- 216
There are times when you want to vertically center on a page. Is it possible to accomplish this by including a table cell within your overall css layout. I have been experimenting with this but the results are unpredicatable ( the Vertically centered dynamic content table cell is either too narrow or the containing div is too wide depending on browser).
Is this possible to achieve? i have included a simple page layout meant to display as follows
Title
Link1 Link2
More Links
More Links Vertically centered dynamic content
More Links
Footer
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
<html>
<head>
<style type="text/css">
<!--
/* screen width 500px. Do seperate style sheets for each screen resolution */
.wrapper{
width:500px;
margin-left:auto;
margin-right:auto;
}
.title{
background-color:#0000FF;
}
.centInline{
text-align:center;
}
.links{
background-color:#FF00FF;
}
.leftbox{
background-color:#00FFFF;
margin-top :50px;
text-align:left;
width : 150px;
float:left;
}
.rightbox{
background-color:#00FF00;
margin-top :50px;
margin-left : 50px;
height:400px;
}
.righttablecell{
display: table-cell;
vertical-align: middle;
background-color:#00FFFF;
}
.footer{
background-color:#00FFFF;
margin-top:450px;
border-top:1px solid #FFFFFF;
clear:both;
}
-->
</style>
</head>
<body style="margin:0;padding:0;">
<div class="wrapper">
<div class="title"><p class="centInline">Title</p></div>
<div class="links">link1 | link2</div>
<div class="leftbox">MoreLinks1<br>MoreLinks2<br>MoreLinks3<br></div>
<div class="rightbox">
<table style = "width: 100%;height: 100%">
<tr><td class="righttablecell">Vertically centered dynamic content</td></tr></table>
</div>
<div class="footer"><p class="centInline">Footer</p></div>
</div>
</body>
</html>
Is this possible to achieve? i have included a simple page layout meant to display as follows
Title
Link1 Link2
More Links
More Links Vertically centered dynamic content
More Links
Footer
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
<html>
<head>
<style type="text/css">
<!--
/* screen width 500px. Do seperate style sheets for each screen resolution */
.wrapper{
width:500px;
margin-left:auto;
margin-right:auto;
}
.title{
background-color:#0000FF;
}
.centInline{
text-align:center;
}
.links{
background-color:#FF00FF;
}
.leftbox{
background-color:#00FFFF;
margin-top :50px;
text-align:left;
width : 150px;
float:left;
}
.rightbox{
background-color:#00FF00;
margin-top :50px;
margin-left : 50px;
height:400px;
}
.righttablecell{
display: table-cell;
vertical-align: middle;
background-color:#00FFFF;
}
.footer{
background-color:#00FFFF;
margin-top:450px;
border-top:1px solid #FFFFFF;
clear:both;
}
-->
</style>
</head>
<body style="margin:0;padding:0;">
<div class="wrapper">
<div class="title"><p class="centInline">Title</p></div>
<div class="links">link1 | link2</div>
<div class="leftbox">MoreLinks1<br>MoreLinks2<br>MoreLinks3<br></div>
<div class="rightbox">
<table style = "width: 100%;height: 100%">
<tr><td class="righttablecell">Vertically centered dynamic content</td></tr></table>
</div>
<div class="footer"><p class="centInline">Footer</p></div>
</div>
</body>
</html>