Skip to content

Instantly share code, notes, and snippets.

@totaku
Last active March 15, 2017 18:41
Show Gist options
  • Save totaku/c3b715d938b90df49329 to your computer and use it in GitHub Desktop.
Save totaku/c3b715d938b90df49329 to your computer and use it in GitHub Desktop.
Center css
.center {
top: 50%; /* Отступ в процентах от верхнего края окна */
left: 50%; /* Отступ в процентах от левого края окна */
width: 450px; /* Ширина блока */
height: 450px; /* Высота блока */
position: absolute; /* Абсолютное позиционирование блока */
margin-top: -225px; /* Отрицательный отступ от верхнего края страницы, должен равняться половине высоты блока со знаком минус */
margin-left: -225px; /* Отрицательный отступ от левого края страницы, должен равняться половине высоты блока со знаком минус */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment