CSSStyleDeclaration: thuộc tính cssFloat
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Thuộc tính cssFloat của giao diện CSSStyleDeclaration trả về kết quả của việc gọi CSSStyleDeclaration.getPropertyValue() với float làm đối số.
Khi thiết lập, nó gọi CSSStyleDeclaration.setProperty() với float làm đối số đầu tiên và giá trị đã cho làm đối số thứ hai. Giá trị đã cho phải là một giá trị hợp lệ cho thuộc tính float.
Giá trị
Một chuỗi.
Khi được đặt thành giá trị null, giá trị null đó được chuyển đổi thành chuỗi rỗng (""), vì vậy csd.cssFloat = null tương đương với csd.cssFloat = "".
Ví dụ
Trong ví dụ bên dưới, bảng kiểu chứa một quy tắc duy nhất cho .box, có thuộc tính float với giá trị là left. Giá trị này sẽ được trả về bởi cssFloat. Sau đó, chúng ta thiết lập giá trị thành "right" bằng cssFloat và trả về giá trị mới.
.box {
float: left;
inline-size: 300px;
}
let myRules = document.styleSheets[0].cssRules;
let rule = myRules[0];
console.log(rule.style.cssFloat); // "left"
rule.style.cssFloat = "right";
console.log(rule.style.cssFloat); // "right"
Đặc tả kỹ thuật
| Specification |
|---|
| CSS Object Model (CSSOM)> # dom-cssstyleproperties-cssfloat> |