CSS: Format

This commit is contained in:
Rico Sta. Cruz 2018-05-02 09:59:07 +08:00
parent 265faa2759
commit 3fc0bad912
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 86 additions and 83 deletions

169
css.md
View File

@ -24,92 +24,93 @@ keywords:
``` ```
{: .-setup} {: .-setup}
| Selector | Description | | Selector | Description |
| --- | --- | | ----------------- | ----------- |
| `div` | Element | | `div` | Element |
| `.class` | Class | | `.class` | Class |
| `#id` | ID | | `#id` | ID |
| `[disabled]` | Attribute | | `[disabled]` | Attribute |
| `[role="dialog"]` | Attribute | | `[role="dialog"]` | Attribute |
### Combinators ### Combinators
| Selector | Description | | Selector | Description |
| --- | --- | | ------------------- | ----------------- |
| `.parent .child` | Descendant | | `.parent .child` | Descendant |
| `.parent > .child` | Direct descendant | | `.parent > .child` | Direct descendant |
| `.child + .sibling` | Adjascent sibling | | `.child + .sibling` | Adjacent sibling |
| `.child ~ .sibling` | Far sibling | | `.child ~ .sibling` | Far sibling |
### Attribute selectors ### Attribute selectors
| Selector | Description | | Selector | Description |
| --- | --- | | ----------------- | ----------------------------------- |
| `[role="dialog"]` | `=` Exact | | `[role="dialog"]` | `=` Exact |
| `[class~="box"]` | `~=` Has word | | `[class~="box"]` | `~=` Has word |
| `[class|="box"]` | `|=` Exact or prefix (eg, `value-`) | | `[class|="box"]` | `|=` Exact or prefix (eg, `value-`) |
| `[href$=".doc"]` | `$=` Ends in | | `[href$=".doc"]` | `$=` Ends in |
| `[class*="-is-"]` | `*=` Contains | | `[class*="-is-"]` | `*=` Contains |
### Pseudo-classes ### Pseudo-classes
| Selector | Description | | Selector | Description |
| --- | --- | | -------------------- | ------------------------ |
| `:target` | eg, `h2#foo:target` | | `:target` | eg, `h2#foo:target` |
| --- | --- | | --- | --- |
| `:disabled` | | | `:disabled` | |
| `:focus` | | | `:focus` | |
| `:active` | | | `:active` | |
| --- | --- | | --- | --- |
| `:nth-child(3)` | 3rd child | | `:nth-child(3)` | 3rd child |
| `:nth-child(3n+2)` | 2nd child in groups of 3 | | `:nth-child(3n+2)` | 2nd child in groups of 3 |
| `:nth-child(-n+4)` | | | `:nth-child(-n+4)` | |
| --- | --- | | --- | --- |
| `:nth-last-child(2)` | | | `:nth-last-child(2)` | |
| `:nth-of-type(2)` | | | `:nth-of-type(2)` | |
| --- | --- | | --- | --- |
### Pseudo-class variations ### Pseudo-class variations
| Selector | | Selector |
| --- | | ----------------- |
| `:first-of-type` | | `:first-of-type` |
| `:last-of-type` | | `:last-of-type` |
| `:nth-of-type(2)` | | `:nth-of-type(2)` |
| `:only-of-type` | | `:only-of-type` |
| --- | | --- |
| `:first-child` | | `:first-child` |
| `:last-child` | | `:last-child` |
| `:nth-child(2)` | | `:nth-child(2)` |
| `:only-child` | | `:only-child` |
{: .-left-align} {: .-left-align}
Fonts ## Fonts
-----
{: .-left-reference} {: .-left-reference}
### Properties ### Properties
| Property | Description | | Property | Description |
| --- | --- | | ------------------ | ------------------------------------ |
| `font-family:` | `<font>, <fontN>` | | `font-family:` | `<font>, <fontN>` |
| `font-size:` | `<size>` | | `font-size:` | `<size>` |
| `letter-spacing:` | `<size>` | | `letter-spacing:` | `<size>` |
| `line-height:` | `<number>` | | `line-height:` | `<number>` |
| --- | --- | | --- | --- |
| `font-weight:` | `bold` `normal` | | `font-weight:` | `bold` `normal` |
| `font-style:` | `italic` `normal` | | `font-style:` | `italic` `normal` |
| `text-decoration:` | `underline` `none` | | `text-decoration:` | `underline` `none` |
| --- | --- | | --- | --- |
| `text-align:` | `left` `right` `center` `justify` | | `text-align:` | `left` `right` `center` `justify` |
| `text-transform:` | `capitalize` `uppercase` `lowercase` | | `text-transform:` | `capitalize` `uppercase` `lowercase` |
{: .-key-values} {: .-key-values}
### Shorthand ### Shorthand
{: .-prime} {: .-prime}
| `font:` | `italic` | `400` | `14px` | `/` | `1.5` | `sans-serif` | | | style | weight | size (required) | | line-height | family |
| | style | weight | size (required) | | line-height | family (required) | | ------- | -------- | ------ | --------------- | --- | ----------- | ----------------- |
| `font:` | `italic` | `400` | `14px` | `/` | `1.5` | `sans-serif` |
| | style | weight | size (required) | | line-height | family (required) |
{: .-css-breakdown} {: .-css-breakdown}
### Example ### Example
@ -126,18 +127,17 @@ color: #aa3322;
```css ```css
text-transform: capitalize; /* Hello */ text-transform: capitalize; /* Hello */
text-transform: uppercase; /* HELLO */ text-transform: uppercase; /* HELLO */
text-transform: lowercase; /* hello */ text-transform: lowercase; /* hello */
``` ```
Background ## Background
----------
{: .-left-reference} {: .-left-reference}
### Properties ### Properties
| Property | Description | | Property | Description |
| --- | --- | | ------------------------ | ---------------------------------------- |
| `background:` | _(Shorthand)_ | | `background:` | _(Shorthand)_ |
| --- | --- | | --- | --- |
| `background-color:` | `<color>` | | `background-color:` | `<color>` |
@ -151,39 +151,42 @@ Background
### Shorthand ### Shorthand
| | color | image | positionX | positionY | | size | repeat | attachment |
| ------------- | ------ | ------------- | --------- | --------- | --- | -------------- | ----------- | ---------- |
| `background:` | `#ff0` | `url(bg.jpg)` | `left` | `top` | `/` | `100px` `auto` | `no-repeat` | `fixed;` | | `background:` | `#ff0` | `url(bg.jpg)` | `left` | `top` | `/` | `100px` `auto` | `no-repeat` | `fixed;` |
| `background:` | `#abc` | `url(bg.png)` | `center` | `center` | `/` | `cover` | `repeat-x` | `local; ` | | `background:` | `#abc` | `url(bg.png)` | `center` | `center` | `/` | `cover` | `repeat-x` | `local;` |
| | color | image | positionX | positionY | | size | repeat | attachment | | | color | image | positionX | positionY | | size | repeat | attachment |
{: .-css-breakdown} {: .-css-breakdown}
### Multiple backgrounds ### Multiple backgrounds
```css ```css
background: background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
linear-gradient(to bottom, rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('background.jpg') center center / cover, #333;
url('background.jpg') center center / cover, ```
#333;
```
Animation ## Animation
---------
{: .-left-reference} {: .-left-reference}
### Properties ### Properties
| `animation:` | _(shorthand)_ | | Property | Value |
| `animation-name:` | `<name>` | | ---------------------------- | -------------------------------------------------- |
| `animation-delay:` | `<time>ms` | | `animation:` | _(shorthand)_ |
| `animation-duration:` | `<time>ms` | | `animation-name:` | `<name>` |
| `animation-direction:` | `normal` `reverse` `alternate` `alternate-reverse` | | `animation-delay:` | `<time>ms` |
| `animation-iteration-count:` | `infinite` `<number>` | | `animation-duration:` | `<time>ms` |
| `animation-direction:` | `normal` `reverse` `alternate` `alternate-reverse` |
| `animation-iteration-count:` | `infinite` `<number>` |
| `animation-timing-function:` | `ease` `linear` `ease-in` `ease-out` `ease-in-out` | | `animation-timing-function:` | `ease` `linear` `ease-in` `ease-out` `ease-in-out` |
{: .-key-values} {: .-key-values}
### Shorthand ### Shorthand
| `animation:` | `bounce` | `300ms` | `linear` | `100ms` | `infinite` | `alternate-reverse` | | | name | duration | timing-function | delay | count | direction |
| | name | duration | timing-function | delay | count | direction | | ------------ | -------- | -------- | --------------- | ------- | ---------- | ------------------- |
| `animation:` | `bounce` | `300ms` | `linear` | `100ms` | `infinite` | `alternate-reverse` |
| | name | duration | timing-function | delay | count | direction |
{: .-css-breakdown} {: .-css-breakdown}
### Example ### Example