Description
The Width
property in the Sandbox.UI.BaseStyles
class represents the width
CSS property. It allows you to specify the width of an element using the Sandbox.UI.Length
type, which can be a specific length value or a percentage. This property is nullable, meaning it can be set to null
to indicate that the width is not explicitly defined.
Usage
To use the Width
property, you can assign it a value of type Sandbox.UI.Length
. This can be done by specifying a fixed value, such as pixels, or a percentage of the parent element's width. If you want to remove the width setting, you can set this property to null
.
Example
// Example of setting the Width property
var styles = new BaseStyles();
styles.Width = new Length(100, LengthUnit.Pixel); // Set width to 100 pixels
// Example of setting the Width property to a percentage
styles.Width = new Length(50, LengthUnit.Percent); // Set width to 50% of the parent element
// Example of clearing the Width property
styles.Width = null; // Remove explicit width setting