docs: add css-tips section (#239)
This commit is contained in:
parent
fef206c12f
commit
917d19ad56
3 changed files with 80 additions and 7 deletions
78
resources/docs/extras/css-tips.md
Normal file
78
resources/docs/extras/css-tips.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# CSS Tips
|
||||
|
||||
## Inline syntax
|
||||
|
||||
For simple use cases, the `css` property can be written as a HTML inline styles (without any CSS selector). CSS rules will apply to the widget container element.
|
||||
|
||||
```css
|
||||
opacity: 0.5; /* make the widget's transparent */
|
||||
font-size: 120%; /* increase font-size */
|
||||
```
|
||||
|
||||
|
||||
## Selector syntax
|
||||
|
||||
CSS selectors can be used to apply styles to specific elements:
|
||||
|
||||
```css
|
||||
:host {
|
||||
/* style for the widget container
|
||||
& { } also works (deprecated)
|
||||
*/
|
||||
}
|
||||
|
||||
.label {
|
||||
/* style for the .label elements */
|
||||
}
|
||||
|
||||
> .label {
|
||||
/* style for the direct child .label element */
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
!!! tip ""
|
||||
Mixing Inline and Selector syntaxes doesn't work, once you use selectors, you have to use the `:host` selector to target the widget's container element.
|
||||
|
||||
## Layering: `z-index`
|
||||
|
||||
Z-Axis ordering can be set using the `z-index` rule. Absolutely positionned widgets (when `top` or `left` is different from `auto`) have `z-index:10;` by default.
|
||||
|
||||
## Layering: `pointer-events`
|
||||
|
||||
To make a widget ignore interactions (ie to be able to click through it), add `pointer-events:none;`.
|
||||
|
||||
!!! note ""
|
||||
This is always ignored when the editor is enabled.
|
||||
|
||||
## Responsive sizing
|
||||
|
||||
In most cases, using percentages in `height` and `width` will do. CSS `calc()` function can help in some cases:
|
||||
|
||||
```css
|
||||
:host {
|
||||
|
||||
width: calc(100% - 100rem);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Media queries can also be used:
|
||||
|
||||
```css
|
||||
@media screen and (min-width: 768px) {
|
||||
|
||||
:host {
|
||||
|
||||
/* style the container if the screen is bigger than 768px */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Size units
|
||||
|
||||
- use `rem` instead of `px` (`px` values will not scale when zooming)
|
||||
- use `%` for font-size
|
||||
|
|
@ -49,13 +49,7 @@ All widgets share a set of generic properties described below.
|
|||
### `css`<i class="md-icon" title="dynamic">flash_on</i>
|
||||
- type: `string`
|
||||
- default: *empty*
|
||||
- usage: the `css` property can be used to override inherited [theming](../extras/theming.md) variables. Also, some widgets expose specific theming variables that allow a finer customization. Standard `css` properties can be applied to the widget's root element through this property, `css` selectors can also be used apply custom styles to the widget's children.
|
||||
- examples:
|
||||
- `border-radius:5rem; .label {font-size: 20rem}` will round the widget's corners and increase its label's font-size and all its children's labels'
|
||||
- `border-radius:5rem; > .label {font-size: 20rem}` will round the widget's corners and increase its label's font-size (the `>` selector targets only the direct children of the widget element)
|
||||
|
||||
!!! tip "& { }"
|
||||
The `&` selector can be used to target the widget container.
|
||||
- usage: applies CSS rules to widget. See [css tips](../extras/css-tips.md).
|
||||
|
||||
## Value
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ pages:
|
|||
- Maths: widgets/maths.md
|
||||
- Extras:
|
||||
- Advanced property syntax: extras/advanced-property-syntax.md
|
||||
- CSS Tips: extras/css-tips.md
|
||||
- Theming: extras/theming.md
|
||||
- URL options: extras/url-options.md
|
||||
- Remote control: extras/remote-control.md
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue