Kiểu phông chữ
Thí dụ
Đặt kích thước phông chữ của một phần tử thành "x-large":
document.getElementById("demo").style.fontSize = "x-large";
Định nghĩa và Cách sử dụng
Thuộc tính fontSize đặt hoặc trả về kích thước phông chữ của văn bản.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
fontSize | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Trả lại thuộc tính fontSize:
object.style.fontSize
Đặt thuộc tính fontSize:
object.style.fontSize = "value|initial|inherit"
Giá trị tài sản
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 |
Chi tiết kỹ thuật
Giá trị mặc định: | Trung bình |
---|---|
Giá trị trả lại: | Một chuỗi, đại diện cho kích thước phông chữ của văn bản trong phần tử |
Phiên bản CSS | CSS1 |
Các ví dụ khác
Thí dụ
Một minh chứng về các giá trị có thể có:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontSize = listValue;
Thí dụ
Trả về kích thước phông chữ của một phần tử:
alert(document.getElementById("demo").style.fontSize);
Các trang liên quan
Hướng dẫn CSS: Phông chữ CSS
Tham chiếu CSS: thuộc tính font-size
Tham chiếu DOM HTML: thuộc tính phông chữ
❮ Đối tượng phong cách