Właściwość rozmiaru czcionki stylu
Przykład
Ustaw rozmiar czcionki elementu na „x-large”:
document.getElementById("demo").style.fontSize = "x-large";
Definicja i użycie
Właściwość fontSize ustawia lub zwraca rozmiar czcionki tekstu.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
fontSize | Yes | Yes | Yes | Yes | Yes |
Składnia
Zwróć właściwość fontSize:
object.style.fontSize
Ustaw właściwość fontSize:
object.style.fontSize = "value|initial|inherit"
Wartości nieruchomości
Value | Description |
---|---|
xx-small x-small small medium large x-large xx-large |
Sets the size of the font to different fixed sizes, from xx-small to xx-large |
smaller | Decreases the font-size by one relative unit |
larger | Increases the font-size by one relative unit |
length | Defines the font-size in length units |
% | Sets the font-size to a % of the parent element's font size |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Szczegóły techniczne
Domyślna wartość: | średni |
---|---|
Wartość zwrotu: | String, reprezentujący rozmiar czcionki tekstu w elemencie |
Wersja CSS | CSS1 |
Więcej przykładów
Przykład
Demonstracja możliwych wartości:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontSize = listValue;
Przykład
Zwróć rozmiar czcionki elementu:
alert(document.getElementById("demo").style.fontSize);
Powiązane strony
Samouczek CSS: Czcionka CSS
Dokumentacja CSS: właściwość rozmiaru czcionki
Odniesienie HTML DOM: właściwość czcionki
❮ Obiekt stylu