keyframes
:opacity
andtransform
are the only properties that are optimized in browsers and should be used in keyframesh1
is very important for SEO; it should contain webpage title and what about the page isdisplay: block
- utilizes the whole available width and applies line breaks- properties related to
font
are inherited;padding
is not span
- used when you want to style texts differently- reset universal selector:
*::after,
::before {
margin: 0;
padding: 0;
box-sizing: inherit;
}
and
body {
box-sizing: border-box;
}
backface-visibility: hidden
- hides a element's background during animations; good fix for shaking effect- good practice in giving CSS classes to elements:
btn btn-green
;btn
class defines common properties for all buttons,btn-green
class defines green color of the specific button - centering options:
absolute
withtransform: translate
child + closestrelative
parent is a reference (texts)display: inline-block
child +text-align: center
parent (buttons - treated as inline text);absolute
withtop: 0; left: 0
child + closestrelative
parent is a referencemargin: 0 auto
center block element inside another block element
padding
- inside element (button shape)margin
- whitespaces (between elements)- pseudo-classes - states
transition: all
- easier version ofanimation
; used in initial state (e. g. visited pseudo-class) to tell that all properties (states) are enabled for animationsafter
pseudo-element - has to havecontent
anddisplay
element (even empty); treated like a child of the element- fade in/out effect:
transition: all Xs
+opacity: 0
in e. g. hover pseudo-class animation-fill-mode: backwards
- applies effects from0%
state before a delayed animation starts- root font size:
html { font-size: 62.5% }
(by default results in 10px font size) - Layout: Component-Driven Design, Atomic Design (Brad Frost)
- Naming classes: BEM, OO CSS, Smacss
- Architecture: 7-1 Pattern, ITCSS, Smacss
- fix for collapsed child elements when using float in parent which results in 0 height:
.clearfix::after {
content: "";
clear: both;
display: table;
}
-
responsive design principles
- fluid grids and layouts - using % instead od px for lengths, especially for widths
- flexible/responsive images - dimension usually defined in %
- media queries - changing styles on certain viewport widths (breakpoints)
-
layout types
- float layouts - boxes side by side using float
- flexbox - laying elements in 1-dimensional row
- CSS grid - laying elements in 2-dimensional grid
-
standard row width in grid -
max-width: 1140px
(in rems) -
calc
function - in native CSS can contain mixed units, in SCSS cannot (in preprocessing stage Sass does not know what % and rem is) -
main
- HTML5 element, tells websites it is main part of our site -
background-image: linear-gradient(to right, color1, color2); -webkit-background-clip: text; color: transparent;
-
transform: skewX(1deg)
-
.u-center-text { text-align: center }
-
arrow symbol:
&rarr
(HTML entities) -
show back side of a card:
transform: rotateY(-180deg); perspective: 150rem; -moz-perspective: 150 rem;
, perspective should be in a parent element, the bigger value the more smooth the effect is, teh best way is to experiment a little bit, child should hasbackface-visibility: hidden
-
fix for collapsed height of parent when we give
position: absolute
to children - give the same height to the parent that children have -
background-blend-mode: screen
-
fix for child overlapping parent -
overflow: hidden
-
clip-path: polygon(...)
, copy-paste-webkit-...
for support in all browsers -
test-transform: uppercase;
-
box-decoration-break: clone
- applies all decorations of an element to all elements created by this element (e. g. padding), need copy-paste of-webkit-...
-
border-top-left-radius: 3px
- rounding of one corner -
shape-outside
, element has to be floated -
filter
- blur, brightness -
object-fit: cover
- pretty similar tobackground-size: cover
, fill does not remain aspect ratio