mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add reference for fractional.
This commit is contained in:
28
docs/styles/css_units/fractional.md
Normal file
28
docs/styles/css_units/fractional.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Fractional
|
||||
|
||||
## Syntax
|
||||
|
||||
--8<-- "docs/styles/snippets/fractional_syntax.md"
|
||||
|
||||
!!! warning
|
||||
|
||||
Not to be confused with the [percentage](./percentage.md) unit nor with the [scalar](./scalar.md) unit.
|
||||
|
||||
## Examples
|
||||
|
||||
```css
|
||||
Widget {
|
||||
text-opacity: 0.45;
|
||||
text-opacity: 45%;
|
||||
}
|
||||
```
|
||||
|
||||
```py
|
||||
widget.styles.text_opacity = 0.45
|
||||
widget.styles.text_opacity = "45%"
|
||||
```
|
||||
|
||||
## Used by
|
||||
|
||||
- [`opacity`](../opacity.md)
|
||||
- [`text-opacity`](../text_opacity.md)
|
||||
@@ -5,6 +5,7 @@ Many CSS rules accept units of some sort, as opposed to a set of values.
|
||||
The different CSS units are:
|
||||
|
||||
- [color](./color.md) – e.g., to set the [background color](../background.md);
|
||||
- [fractional](./fractional.md) – e.g., to set a widget's [`opacity`](../opacity.md);
|
||||
- [integer](./integer.md) – e.g., to set the [`grid-size`](../grid/grid_size.md);
|
||||
- [percentage](./percentage.md) – e.g., to set the transparency of the [background color](../background.md); and
|
||||
- [scalar](./scalar.md) – e.g., to set the [width](../width.md) of a widget.
|
||||
|
||||
6
docs/styles/snippets/fractional_syntax.md
Normal file
6
docs/styles/snippets/fractional_syntax.md
Normal file
@@ -0,0 +1,6 @@
|
||||
A fractional value can be set to
|
||||
|
||||
- a float between 0 and 1 (e.g., `0.45`); or
|
||||
- a percentage between 0% and 100% (e.g., `45%`).
|
||||
|
||||
Values outside their ranges will be clamped.
|
||||
@@ -57,6 +57,7 @@ nav:
|
||||
- CSS units:
|
||||
- "styles/css_units/index.md"
|
||||
- "styles/css_units/color.md"
|
||||
- "styles/css_units/fractional.md"
|
||||
- "styles/css_units/integer.md"
|
||||
- "styles/css_units/percentage.md"
|
||||
- "styles/css_units/scalar.md"
|
||||
|
||||
Reference in New Issue
Block a user