Frontend Tips - herougo/SoftwareEngineerKnowledgeRepository GitHub Wiki
-
Use HSL instead of RGB for colours (e.g. easier to see changes such as lightness differences)
-
Avoid Viewport units (i.e. 100vw, 100vh) because
- they do not account for scroll bars
- they do not account for address bars on mobile
- zooms don't work
-
Avoid position absolute unless necessary (e.g. flex and grid not working)
-
1 h1 per page (use h2 etc for multiple headings).
-
Try to "let the browser work for you". For example, instead of setting a constant height and media queries, use min-height to prevent overflow (or max-width).
-
You can use
--clr-neutral-hsl-300: 241, 100%, 89%thenhsl(var(--clr-neutral-hsl-200), 0.7). -
Short forms
- fs = font size
- fw = font weight
Sources:
- https://www.youtube.com/watch?v=EJtmfkKulNA
- https://www.youtube.com/watch?v=veEqYQlfNx8
- https://www.youtube.com/watch?v=fF_NVrd1s14
- https://www.youtube.com/watch?v=A6IpZ2GlMM4
- https://www.youtube.com/watch?v=x4u1yp3Msao
Tricks
- Making the body height 100%.
html,
body {
height: 100%; /* just body may not be enough */
}