mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add CSS type number.
This commit is contained in:
31
docs/css_types/number.md
Normal file
31
docs/css_types/number.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# <number>
|
||||
|
||||
The `<number>` CSS type represents a real number, which can be an integer or a number with a decimal part (akin to a `float` in Python).
|
||||
|
||||
## Syntax
|
||||
|
||||
--8<-- "docs/snippets/type_syntax/number.md"
|
||||
|
||||
## Examples
|
||||
|
||||
### CSS
|
||||
|
||||
```sass
|
||||
* {
|
||||
css-rule: 6 /* Integers are numbers */
|
||||
css-rule: -13 /* Numbers can be negative */
|
||||
css-rule: 4.75 /* Numbers can have a decimal part */
|
||||
css-rule: -73.73
|
||||
}
|
||||
```
|
||||
|
||||
### Python
|
||||
|
||||
In Python, a rule that expects a CSS type `<number>` will accept an `int` or a `float`:
|
||||
|
||||
```py
|
||||
number = 6 # ints are numbers
|
||||
number = -13 # ints can be negative
|
||||
number = 4.75 # floats are numbers
|
||||
number = -73.73 # negative floats too
|
||||
```
|
||||
1
docs/snippets/type_syntax/number.md
Normal file
1
docs/snippets/type_syntax/number.md
Normal file
@@ -0,0 +1 @@
|
||||
A [`<number>`](/css_types/number) is an [`<integer>`](/css_types/integer), optionally followed by the decimal point `.` and a decimal part composed of one or more digits.
|
||||
Reference in New Issue
Block a user