DOCTYPE html PUBLIC W3C DTD XHTML Transitional EN http www w3 org TR x

 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head>
<title>XHTML divs</title>
<style type="text/css">
html {
height:100%;
}
body {
margin:0;
padding:0;
height:100%;
}
#lb_table {
display: table;
width:100%;
height: 100%;
position: relative;
//top: 50%;
//height: auto;
}
#lb_table_cell {
display: table-cell;
height: 100%;
vertical-align: middle;
position: relative;
text-align: center;
//height: auto;
//top: -50%;
}
-,#lb_table_cell{
top: 0;
}
</style>
</head>
<body>
<div id="lb_table"><div id="lb_table_cell">
<div style="width: 400px; border: 2px solid green; margin: 0 auto;text-align:left;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</div>
</div></div>
<!--[if IE 7]>
<script type="text/javascript">
var ie7_lb_table = document.getElementById('lb_table');
var ie7_lb_cell = document.getElementById('lb_table_cell');
function ie7fixVertical()
{
if(ie7_lb_table.clientHeight>ie7_lb_table.parentNode.clientHeight)
{
ie7_lb_cell.style.top = '0';
ie7_lb_table.style.height = '100%';
ie7_lb_cell.style.top = '-50%';
}
else
{
ie7_lb_table.style.height = 'auto';
}
}
ie7fixVertical();
ie7_lb_cell.style.top = '-50%';
window.onresize = ie7fixVertical;
</script>
<![endif]-->
</body>
</html>