en.javascript.info/12-css-for-js/6-css-center/3-vertical-align-table-cell-position/solution.md
2015-02-27 13:21:58 +03:00

29 lines
No EOL
886 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Подсказка
Центрирование не работает из-за `position: absolute`.
# Решение
Центрирование не работает потому, что `position: absolute` автоматически меняет элементу `display` на `block`.
В однострочном случае можно сделать центрирование при помощи `line-height`:
```html
<!--+ run -->
<style>
.arrow {
position: absolute;
height: 60px;
border: 1px solid black;
font-size: 28px;
*!*
line-height: 60px;
*/!*
}
</style>
<div class="arrow">«</div>
```
Если же центрировать нужно несколько строк или блок, то есть и другие [техники центрирования](/css-center), которые сработают без `display:table-cell`.