CSS
up:: Programming ⚐
- CSS Obsidian Snippets
- CSS tweaks for Obsidian Publish
- CSS tweaks for Obsidian Bible Study
- Generate utility classes from a JSON: https://tokens2css.nanools.com
Notes
Link hovers
Resources
- Transition.css - easy transitions with clip-path
- Home | Utopia
- CSS Shadow Palette Generator
- Multicolor CSS Gradients, JPG Downloads, 100% Free! | Gradienta
- CSS Shadow Gradients — Generator
- CSS talks you have to see
- Pico.css • Minimal CSS Framework for semantic HTML
Learning
- Learn
grid
orflexbox
. Usually,grid
is easier to get started with. - Overview on getting started with CSS
- https://web.dev/learn/css/
- CSS Talk (recommended by Matthias Ott
- CSS Grid Generator
Principles
- Design for mobile first. It is much easier to scale for desktop than to reduce for mobile. Also, mobile is becoming very prevalent, e.g. is preferred by Google search.
- Connected to the above: Add complexity in media queries. That often means mobile-first. Don’t start with a desktop
display: flex
to set three columns, only to overwrite that with a media query for mobile. Go for the least overwrites possible. For a complex mobile navigation, add that in the media query. - Matthias Ott: How I structure my CSS
- Seperate layout classes (eg.
.columns
) from classes that style content (eg..clr-accent
). Tip: this can be done via|
symbol since it doesn’t get picked up. Example:<div class="columns | clr-400 inverse-background"></div>
CSS Syntax
Common selectors:
- Class: Attribute of HTML
.class-name
- ID (unique):
#id
Selector Combinations:
- Target specific selector:
.anchestor .child
- Apply for both selectors:
.big, .large
Inspiration
Snippets
Flexbox
Grid
Creates three evenly sized columns. Content overflows into additional rows.
Getting started on a new project
- Add reset CSS Reset
- Set up custom properties
- Add utility classes
Setting up variables
From Kevin Powell (26:00)
ff
stands for font-family. By setting body
and headings
(also can be named accent) seperately, it is easy to change later on.
clr
stands for color. 100
is the lightest value, 900
the darkest.
fs
stands for font-size. The numbers are based on the font-weight numbers. 400
is the body
size.
Utility classes
On the bottom of reset.css
rem and em
rem
looks at the root. Use this for text.
em
multiplies the font-size of the element. Use this for margins and padding to grow automatically.
Set a container for content
“Tag”
Replace svgs
- Find an icon (eg. on Material Design Icons) and copy scg
- Encode via URL-encoder for SVG
- Replace icon:
Aligning
Resize svgs
Animate
Only transform
and opacity
are performant to animate.
Numbered rows
By SIRvb
on Discord
Responsive images
Learn how to create a responsive CSS grid layout - YouTube
Grid auto-fit
Magically fits the columns.