<selector > {
<property>: <value>;
}
h1, body
#id-name
.class-name
[<attr>*="<str>"]
, ^
= starts with, $
= ends with*
<selector>:<pseudo-class> {...}
<selector>:nth-child(<n> | even | odd)
<selector>::<pseudo-element> {...}
{ content: "some content to add without changing html" }
<selector> <combinator> <selector2> {...}
>
<literal space>
+
~
To select all classes containing str
in name:
[class*="str"] ...
To select all classes that start with strt
or end with end
use:
[class^="strt"] ...
[class$="end"] ...
To center image: margin: 0 auto
To center text: text-align: center
Group duplicates: h1, h2, .header-class, #header-id { ... }
Absolute units: px, pt, cm, mm, in
Relative units: em, rem, vw, vh, %
Standard html size is around 16px
Use relative units for responsive UI
Build-in names white
, blue
, black
, red
RGB(A) (Red, Blue, Green, Alpha) rgb(x, y, z)
Hexadecimal #000000
-> #FFFFFF
#RRBBGG
HSL (Hue, Saturation%, Lightness%)
content, padding, border, margin.
Parent:
display: flex
flex-direction: row (default on web) | column (default on react-native)
justify-content: center | ...
(main axis)align-items: center | flex-start | ...
(cross axis)flex-wrap: wrap | nowrap
Children:
flex-grow: <number>
amount of space an item will takeflex-shrink: <number>
same as aboveflex-basis: <value>
Initial sizeflex: <num> <num> <val>
align-self: center | ...
Center Div
<div class="outer">This text should be in center!</div>
<style>
.outer {
display: flex /* grid */;
justify-content: center;
align-items: center;
height: 100%;
}
</style>
Change svg color using css filter
Add the SVG image using an <img>
tag.
<img src="dotted-arrow.svg" class="filter-green" />
To filter to a specific color, use the following Codepen to convert a hex color code to a CSS filter:
For example, output for #00EE00 is
filter: invert(42%) sepia(93%) saturate(1352%) hue-rotate(87deg) brightness(119%) contrast(119%);
Add the CSS filter into this class.
.filter-green {
filter: invert(48%) sepia(79%) saturate(2476%) hue-rotate(86deg) brightness(
118%
) contrast(119%);
}