CSSUnitValue: unit property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Thuộc tính chỉ đọc CSSUnitValue.unit của giao diện CSSUnitValue trả về chuỗi cho biết loại đơn vị.

Giá trị

Một chuỗi.

Ví dụ

Ví dụ sau tạo CSSPositionValue từ các hàm khởi tạo CSSUnitValue, sau đó truy vấn CSSUnitValue.unit.

js
const pos = new CSSPositionValue(
  new CSSUnitValue(5, "px"),
  new CSSUnitValue(10, "em"),
);

console.log(pos.x.unit); // "px"
console.log(pos.y.unit); // "em"

Thông số kỹ thuật

Specification
CSS Typed OM Level 1
# dom-cssunitvalue-unit

Tương thích trình duyệt

Xem thêm