Skip to content


Как отцентрировать DIV по вертикали

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css" media="screen"><!--
#horizon {
  color: white;
  background-color: #0ff;
  text-align: center;
  position: absolute;
  top: 50%;
  left: 0px;
  width: 100%;
  height: 1px;
  visibility: hidden;
  display: block
  }
#content {
  background-color: #f00;
  margin-left: -247px;
  position: absolute;
  top: -187px;
  left: 50%;
  width: 495px;
  height: 375px;
  visibility: visible
  }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="horizon">
  <div id="content">
    Этот блок отцентрирован по вертикали
  </div>
</div>
</body>
</html>

Результат:

Выравнивание по вертикали с помощью CSS

CSS: как отцентрировать по вертикали

Posted in Веб-приложения.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.