Marco's notes

css

darken browser's scroll bar

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark; // darken browser's scroll bar
  }
}

Color theme using css variable (support dark theme)

/* color theme */
:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --text: var(--gray-900);
  --text-secondary: var(--gray-700);
  --text-hint: var(--gray-500);
  --background: var(--gray-50);
  --background-secondary: var(--gray-200);
  --border: var(--gray-100);
  --link: #0ea5e9;
  --visited: #ec4899;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: var(--gray-50);
    --text-secondary: var(--gray-200);
    --text-hint: var(--gray-400);
    --background: var(--gray-900);
    --background-secondary: var(--gray-800);
    --border: var(--gray-800);
    color-scheme: dark; // darken browser's scroll bar
  }
}

Fluid font size (base font-size is 16px)

@media screen and (min-width: 320px) {
  html {
    font-size: calc(16px + 4 * ((100vw - 320px) / 680));
  }
}
@media screen and (min-width: 1000px) {
  html {
    font-size: 20px;
  }
}

Prevent scroll bar causing page shift

@media screen and (min-width: 960px) {
  html {
    margin-left: calc(100vw - 100%);
    margin-right: 0;
  }
}

Using system font

html {
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,
    sans-serif, Apple Color Emoji, Segoe UI Emoji;
}
code {
  font-family: monospace, monospace;
}
html {
  height: 100%;
}
body {
  height: 100%;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
}

HTML layout would be:

body
  header
  main
  footer
body