In HTML td tag has an attribute named “valign” which can align content vertically. CSS doesnt have such an attribute, so you need to do some magic to achieve such a result. CSS vertical align. Using method described below you will be able to align an element vertically in any height container.
Source code for index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<!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" xml:lang="en">
<head>
<title>DEMO: CSS vertical align</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
.v-outer {
display: table;
#position: relative;
overflow: hidden;
height: 100px;
background: black;
color: white;
width: 100%;
}
.v-middle {
display: table-cell;
#position: absolute;
#top: 50%;
vertical-align: middle;
}
.v-inner {
#position: relative;
#top: -50%;
}
</style>
</head>
<body>
<div class="border v-outer">
<div class="v-middle">
<div class="v-inner">
...content...
</div>
</div>
</div>
</body>
</html>
|