Hi,
You can do this very easily without extra mark up by using display table-cell as already mentioned but support is only ie8+.
For a full cross browser method back to ie5.5. you can do this which requires only one extra element.
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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.outer {
width: 728px;
height: 430px;
background-color: black;
overflow: hidden;
text-align:center;
margin:10px;
}
.banner {
width: 400px;
height: 300px;
background:blue;
}
.companion {
width: 300px;
height: 250px;
background:green;
}
.banner, .companion, .outer b {
vertical-align:middle;
display:inline-block;
}
.outer b {height:100%;width:1px;overflow:hidden}
</style>
</head>
<body>
<div class="outer"><span class="banner">Banner</span><span class="companion">Companion</span></span><b></b></div>
<div class="outer"><span class="banner">Banner</span><b></b></div>
<div class="outer"><span class="companion">Companion</span></span><b></b></div>
</body>
</html>
Bookmarks