CSS line-height Свойство
Пример
Задайте высоту линии для различных элементов <div>:
div.a {
line-height: normal;
}
div.b {
line-height: 1.6;
}
div.c {
line-height:
80%;
}
div.d {
line-height: 200%;
}
Подробнее примеры ниже.
Определение и использование
Свойство line-height
указывает высоту линии.
Примечание: Отрицательные значения не допускаются.
Значение по умолчанию: | normal |
---|---|
Inherited: | yes |
Animatable: | yes. Читайте о animatable |
Version: | CSS1 |
Синтаксис JavaScript: | object.style.lineHeight="30px" |
Поддержка браузера
Номера в таблице указывают первую версию браузера, которая полностью поддерживает свойство.
Свойство | |||||
---|---|---|---|---|---|
line-height | 1.0 | 4.0 | 1.0 | 1.0 | 7.0 |
Синтаксис CSS
line-height: normal|number|length|initial|inherit;
Значения свойств
Значение | Описание | |
---|---|---|
normal | Обычная высота линии. Это значение по умолчанию | |
number | Число, которое будет умножено на текущий размер шрифта для установки высоты линии | |
length | Фиксированная высота линии в пикселах, PT, cm и т.д. | |
% | Высота строки в процентах от текущего размера шрифта | |
initial | Присваивает этому свойству значение по умолчанию. (Читайте о initial) | |
inherit | Наследует это свойство из родительского элемента. (Читайте о inherit) |
Другие примеры
Пример
Задайте высоту линии в пикселах и сантиметрах для различных элементов <div>:
div.a {
line-height: 10px;
}
div.b {
line-height: 30px;
}
div.c {
line-height:
0.5cm;
}
div.d {
line-height: 1cm;
}
Пример
Задайте высоту линии как число для различных элементов <div>:
div.a {
line-height: 0.5;
}
div.b {
line-height: 1.6;
}
div.c {
line-height: 2;
}
Похожие страницы
CSS Справочник: CSS Text
HTML DOM Справочник: lineHeight Свойство