CSSNumericValue: sub() method

Limited availability

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

Phương thức sub() của giao diện CSSNumericValue trừ một số khỏi CSSNumericValue.

Cú pháp

js
sub(number)

Tham số

number

Một số hoặc một CSSMathSum.

Giá trị trả về

Một CSSMathSum.

Ngoại lệ

TypeError

Được ném ra nếu kiểu không hợp lệ được truyền vào phương thức.

Ví dụ

js
let mathSum = CSS.px("23")
  .sub(CSS.percent("4"))
  .sub(CSS.cm("3"))
  .sub(CSS.in("9"));
// In ra "calc(23px - 4% - 3cm - 9in)"
console.log(mathSum.toString());

Thông số kỹ thuật

Specification
CSS Typed OM Level 1
# dom-cssnumericvalue-sub

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