Właściwość wysokości linii CSS
Przykład
Ustaw wysokość linii dla różnych elementów <div>:
div.a {
line-height: normal;
}
div.b {
line-height: 1.6;
}
div.c {
line-height:
80%;
}
div.d {
line-height: 200%;
}
Więcej przykładów „Wypróbuj sam” poniżej.
Definicja i użycie
Właściwość line-height
określa wysokość linii.
Uwaga: wartości ujemne nie są dozwolone.
Domyślna wartość: | normalna |
---|---|
Dziedziczny: | tak |
Animowalny: | tak. Przeczytaj o animacji |
Wersja: | CSS1 |
Składnia JavaScript: | obiekt .style.lineHeight="30px" |
Obsługa przeglądarki
Liczby w tabeli określają pierwszą wersję przeglądarki, która w pełni obsługuje tę właściwość.
Property | |||||
---|---|---|---|---|---|
line-height | 1.0 | 4.0 | 1.0 | 1.0 | 7.0 |
Składnia CSS
line-height: normal|number|length|initial|inherit;
Wartości nieruchomości
Value | Description | Play it |
---|---|---|
normal | A normal line height. This is default | |
number | A number that will be multiplied with the current font-size to set the line height | |
length | A fixed line height in px, pt, cm, etc. | |
% | A line height in percent of the current font size | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Więcej przykładów
Przykład
Ustaw wysokość linii w pikselach i centymetrach dla różnych elementów <div>:
div.a {
line-height: 10px;
}
div.b {
line-height: 30px;
}
div.c {
line-height:
0.5cm;
}
div.d {
line-height: 1cm;
}
Przykład
Ustaw wysokość linii jako liczbę dla różnych elementów <div>:
div.a {
line-height: 0.5;
}
div.b {
line-height: 1.6;
}
div.c {
line-height: 2;
}
Powiązane strony
Samouczek CSS: Tekst CSS
Odniesienie HTML DOM: właściwość lineHeight