惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
U
Unit 42
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
G
Google Developers Blog
Recent Announcements
Recent Announcements
B
Blog RSS Feed
罗磊的独立博客
博客园 - Franky
J
Java Code Geeks
S
SegmentFault 最新的问题
D
DataBreaches.Net
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
腾讯CDC
博客园_首页
美团技术团队
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏

Syntax - Tasty Web Development Treats

Diffs, Trees, and VS Code 2.0 - Syntax #1008 8 Tech Choices to Lock In Before Agentmaxxing - Syntax #1007 Can AI Make Good Design? - Syntax #1006 Programatic and Skill based Video Creation with Remotion - Syntax #1005 TanHacked - Syntax #1004 Skills Skills Skills - Syntax #1003 The Real Pricing of LLMs - Syntax #1002 Managing Deadlines + Stress - Syntax #1001 Syntax Episode 1,000! - Syntax #1000 Writing Maintainable CSS - Syntax #999 How to Fix Vibe Coding - Syntax #998 Rating and Roasting Your Projects - Syntax #997 10 New CSS and HTML APIs - Syntax #996 Next.js Vendor Lock-in No More - Syntax #995 AI Sucks At CSS - Syntax #994 It’s Been A Hell Of Week - Syntax #993 Migrating Legacy Code Just Got Easier - Syntax #992 Vite’s bet on Cloudflare (VOID Framework) - Syntax #991 Vite Is Taking Over (Vite+) - Syntax #990 State of JS 2025 - Syntax #989 Cloudflare’s Next.js Slop Fork - Syntax #988 Remote Coding Agents - Syntax #987 Does Code Quality Matter Anymore? - Syntax #986 Stop putting secrets in .env - Syntax #985 How to Make a DOM Library Render Anything w/ Paolo Ricciuti - Syntax #984 Why I Chose Electron Over Native (And I’d Do It Again) - Syntax #983 Bots Are Ruining the Internet - Syntax #982 Browsers Are Finally Catching Up (Interop 2026) - Syntax #981 AI Coding Explained - Syntax #980 WebMCP: New Standard to Expose Your Apps to AI - Syntax #979
The Surprisingly Exciting World of Print + PDF CSS - Synt...
2024-01-01 · via Syntax - Tasty Web Development Treats
711

January 1st, 2024 × #print-css#css#web-dev

Covers using print CSS for various use cases like shipping labels and recipes. Explains how to load print CSS, use advanced features like CSS counters and @page rules, control page margins and numbering, debug print styles, and generate PDFs.

Wes Bos

Wes Bos Host

Scott Tolinski

Scott Tolinski Host

In this episode of Syntax, Wes and Scott talk about things to consider when printing something from your website or app including loading CSS only for printing, using units in CSS, CSS counters, creating a PDF, naming pages when printing, and more.

Show Notes

  • 00:25:15 Welcome
  • 01:27:04 Syntax Brought to you by Sentry
  • 01:52:00 Examples of how Wes uses print CSS
  • 03:42:16 Using it for invoices or receipts
  • 05:08:24 Delivering a book as a PDF
  • 05:42:16 How do you load CSS only for printing?
  • 10:41:08 Using units in CSS
  • 11:29:15 CSS Counters
  • MDN: CSS Counters

body {
counter-reset: chapter; /* create a chapter counter scope */
}

h1:before {
content: "Section " counter(chapter) " ";
counter-increment: chapter; /* add 1 to chapter */

}
h1 {
        counter-reset: subchapter; /* set section to 0 */
    }
    h2:before {
        content: counter(chapter) "." counter(subchapter) " ";
        counter-increment: subchapter;
    }
    h2 {
        counter-reset: section;
        font-size: 23px;
    }
  • 14:31:10 Named Pages
@page title {
  @top {
    /* no header for title pages */
    content: “”;
   }
}

@page chapter {
  @top {
    content: “This is a chapter page”;
   }
}
  • 15:27:09 Margins, Headers + footers, Page Numbers
  • 18:01:18 Debugging Print CSS
  • 19:57:18 Getting into a PDF
  • Docraptor
  • Playwright
  • Puppeteer
  • JSPdf
  • 24:45:04 Other Things to consider

Syntax: X Instagram Tiktok LinkedIn Threads

Wes: X Instagram Tiktok LinkedIn Threads

Scott: X Instagram Tiktok LinkedIn Threads