- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Centering div content in 2012 using CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
/* align horizontally */
.fu { width: 100%; text-align: center; }
/* align vertically */
@media all and (min-height:0px) { .fu { margin-top: 0px; }}
@media all and (min-height:2px) { .fu { margin-top: 1px; }}
@media all and (min-height:4px) { .fu { margin-top: 2px; }}
@media all and (min-height:6px) { .fu { margin-top: 3px; }}
@media all and (min-height:8px) { .fu { margin-top: 4px; }}
@media all and (min-height:10px) { .fu { margin-top: 5px; }}
@media all and (min-height:12px) { .fu { margin-top: 6px; }}
@media all and (min-height:14px) { .fu { margin-top: 7px; }}
@media all and (min-height:16px) { .fu { margin-top: 8px; }}
@media all and (min-height:18px) { .fu { margin-top: 9px; }}
@media all and (min-height:20px) { .fu { margin-top: 10px; }}
@media all and (min-height:22px) { .fu { margin-top: 11px; }}
.....
.....
.....
@media all and (min-height:1994px) { .fu { margin-top: 997px; }}
@media all and (min-height:1996px) { .fu { margin-top: 998px; }}
@media all and (min-height:1998px) { .fu { margin-top: 999px; }}
</style>
</head>
<body>
<div class="fu">horizontally and vertically centered</div>
</body>
</html>
Центрируем содержимое дива по горизонтали и вертикали :) http://jsfiddle.net/ykrBh/
Stud 02.10.2012 21:41 # 0
ErmineMD 03.10.2012 09:06 # 0
bormand 02.10.2012 21:46 # +2
Snickers 03.10.2012 12:50 # 0
ZX_Spectrum 04.10.2012 23:40 # 0
makc3d 04.10.2012 23:42 # 0
makc3d 04.10.2012 23:45 # 0