Even More CSS Secrets

By Lea Verou (@LeaVerou)

2011-2012

  1. Bouncing transitions
    cubic-bezier() values > 1
  2. Flexible ellipses
    border-radius: 50%
  3. Multiple outlines
    box-shadow spread
  4. Ignore mouse events
    pointer-events: none
  5. Custom code indents
    tab-size
  6. Styling based on sibling count
    :first-child:nth-last-child(n + 8) ~ *
  7. Custom checkboxes & radios
    :checked + label
  8. Improving UX with cursors
    new L3 cursors like not-allowed
  9. Background patterns with pure CSS
    layered gradient tricks
  10. Background image with corner offsets
    4 value background-position

2012-2013

  1. Shadows to indicate scrolling
    gradients & background-attachment: local
  2. Fixed content width, fluid background
    calc(50% - content width / 2)
  3. Lightbox effect
    stacking transitions via transition-delay
  4. Text line background
    background-size, ems, and gradients
  5. Diamond crop
    nested opposite rotate() transforms
  6. Move element along a circle
    transform: rotate(-θ) translate(r) rotate(θ)
  7. Shadows that follow transparency
    filter: drop-shadow()
  8. Blurred element backdrop
    fixed positioning, pseudos, filter: blur()
  9. Hyphenation
    hyphens: auto
  10. Frame by frame animation
    animation-timing-function: steps()
CSS Secrets by O’Reilly on Amazon

Also available in:

  • German
  • Polish
  • Russian
  • Japanese
  • Simplified Chinese
  • Traditional Chinese
  • Korean
  • Bulgarian

Cutout Text

Even More CSS Secrets

on

CSS blend modes 41 32 7.1
89.58%

Characters as images

Fancy borders

4

Line Headings

width: 100% on h1, height on pseudo

Text nodes and pseudo-elements can be flex children

Accessible CSS
Menus
  • Item 1
  • Item 2
  • Item 3

:focus-within 60 52 10.1
80.57%

Variable Fonts for non-variable strokes

Linear Regression -95x+386 Quadratic Regression 65-326x+543

Regression

size weight

Thanks to Black[Foundry] for providing their font Drive for this demo!

Responsive Flex
No media queries added!

Based on Flex-grow 9999 Hack by Joren Van Hee (@jorenvanhee)

Auto-flowing grids
for fun and profit

200px cells

CSS Grid 57 52 10 10.1
91.98%
object-fit 60 36 16 7.1
94.36%

Pie charts


			CSS.registerProperty({
				name: "--value",
				syntax: "<percentage>",
				initialValue: "0%",
				inherits: false
			});
		
conic-gradient() 69 12.1
61.17%
CSS Variables 49 31 15 9.1
91.04%
CSS.registerProperty() ⛳️ ⛳️

Descendant
Grid
Items

display: contents 65 37 11.1
79.41%