ui.Label.style

تعرِض هذه السمة نمط التطبيق المصغّر ActiveDictionary، والذي يمكن تعديله لتعديل أنماط التطبيق المصغّر.

الخصائص التي تعمل مثل نظيراتها في CSS:

  - height وmaxHeight وminHeight (مثلاً ‎100px)

  - width وmaxWidth وminWidth (مثلاً ‎100px)

  - الحشو والهامش (مثل "4px 4px 4px 4px" أو "4px" فقط)

  - color وbackgroundColor (مثل "red" أو ‎#FF0000)

  - border (مثل "1px solid black")

  - borderColor (مثل "أحمر أسود أزرق #FF0000")

  - borderRadius (مثلاً ‎10px)

  - borderStyle (مثلاً، "solid dashed none dotted")

  - borderWidth (مثلاً ‎1px 0px 1px 0px)

  - fontSize (مثلاً ‎24px)

  - fontStyle (مثل "مائل")

  - fontWeight (مثل "bold" أو "100")

  - fontFamily (مثلاً monospace أو serif)

  - textAlign (مثل left أو center)

  - textDecoration (مثل "underline" أو "line-through")

  - whiteSpace (مثلاً nowrap أو pre)

  - shown (صحيح أو خطأ)

خصائص التنسيق المخصّص المسموح بها (اطّلِع على مستندات ui.Panel.Layout):

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

  - position ('top-right', 'top-center', 'top-left', 'bottom-right', ...)

الاستخدامالمرتجعات
Label.style()ui.data.ActiveDictionary
الوسيطةالنوعالتفاصيل
هذا: ui.widgetui.Widgetمثيل ui.Widget

أمثلة

محرِّر الرموز البرمجية (JavaScript)

// Define a UI widget and add it to the map.
var widget = ui.Label({
  value: 'A label',
  style: {width: '400px', height: '200px', fontSize: '40px', color: '484848'}
});
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('backgroundColor', 'lightgray');
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);