ui.Checkbox.style

Trả về kiểu ActiveDictionary của tiện ích. Bạn có thể sửa đổi kiểu này để cập nhật kiểu của tiện ích.

Các thuộc tính hoạt động giống như các thuộc tính tương ứng trong CSS:

  - height, maxHeight, minHeight (ví dụ: "100px")

  - width, maxWidth, minWidth (ví dụ: "100px")

  – khoảng đệm, lề (ví dụ: "4px 4px 4px 4px" hoặc chỉ "4px")

  – color, backgroundColor (ví dụ: "red" hoặc "#FF0000")

  - border (ví dụ: "1px solid black")

  - borderColor (ví dụ: "red black blue #FF0000")

  - borderRadius (ví dụ: "10px")

  - borderStyle (ví dụ: "solid dashed none dotted")

  - borderWidth (ví dụ: "1px 0px 1px 0px")

  - fontSize (ví dụ: "24px")

  - fontStyle (ví dụ: "italic")

  - fontWeight (ví dụ: "bold" hoặc "100")

  - fontFamily (ví dụ: "monospace" hoặc "serif")

  - textAlign (ví dụ: "trái" hoặc "giữa")

  - textDecoration (ví dụ: "underline" hoặc "line-through")

  - whiteSpace (ví dụ: "nowrap" hoặc "pre")

  – hiển thị (true hoặc false)

Các thuộc tính bố cục tuỳ chỉnh được hỗ trợ (xem tài liệu về ui.Panel.Layout):

  - stretch ("horizontal", "vertical", "both")

  - vị trí ("top-right", "top-center", "top-left", "bottom-right", ...)

Cách sử dụngGiá trị trả về
Checkbox.style()ui.data.ActiveDictionary
Đối sốLoạiThông tin chi tiết
this: ui.widgetui.WidgetThực thể ui.Widget.

Ví dụ

Trình soạn thảo mã (JavaScript)

// Define a UI widget and add it to the map.
var widget = ui.Checkbox({label: 'A ui.Checkbox', style: {width: '400px'}});
Map.add(widget);

// View the UI widget's style properties; an ActiveDictionary.
print(widget.style());

// ActiveDictionaries are mutable; set a style property.
widget.style().set('color', 'blue');
print(widget.style());

// Define the UI widget's style ActiveDictionary as a variable.
var widgetStyle = widget.style();
print(widgetStyle);

// Set the UI widget's style properties from the ActiveDictionary variable.
widgetStyle.set({border: '5px solid darkgray'});
print(widgetStyle);