<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CSS on Commentary of Takao</title><link>https://takao.blog/zh-tw/tags/css/</link><description>Recent content in CSS on Commentary of Takao</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Commentary of Takao</copyright><lastBuildDate>Wed, 15 Jul 2026 22:01:08 +0900</lastBuildDate><atom:link href="https://takao.blog/zh-tw/tags/css/index.xml" rel="self" type="application/rss+xml"/><item><title>Isolating Layout Computations via CSS contain 正確的ty</title><link>https://takao.blog/zh-tw/web/performance-css-contain-property/</link><pubDate>Mon, 15 Jun 2026 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/performance-css-contain-property/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/performance-css-contain-property-zh-tw.png" alt="Featured image of post Isolating Layout Computations via CSS contain 正確的ty" /&gt;&lt;h2 id="the-rendering-cost-of-dynamic-content"&gt;The Rendering Cost of Dynamic Content
&lt;/h2&gt;&lt;p&gt;Every time the DOM changes, the browser must recompute styles, layout, and paint. For pages with many interactive widgets—chat feeds, stock tickers, infinite-scroll lists—these recalculations can ripple across the entire document, causing jank and dropped frames.&lt;/p&gt;
&lt;p&gt;The CSS &lt;code&gt;contain&lt;/code&gt; property tells the browser that a subtree is &lt;strong&gt;independent&lt;/strong&gt; from the rest of the page. This enables the engine to skip global recalculations and treat the element as an isolated island.&lt;/p&gt;</description></item><item><title>Optimizing Web Font Loading: 預防ing FOUT and FOIT</title><link>https://takao.blog/zh-tw/web/performance-fonts-loading-optimization/</link><pubDate>Sun, 15 Mar 2026 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/performance-fonts-loading-optimization/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/performance-fonts-loading-optimization-zh-tw.png" alt="Featured image of post Optimizing Web Font Loading: 預防ing FOUT and FOIT" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Web fonts enhance design but come at a cost. While a custom font loads, browsers must decide: show invisible text (&lt;strong&gt;FOIT&lt;/strong&gt; — Flash of Invisible Text) or show a fallback font (&lt;strong&gt;FOUT&lt;/strong&gt; — Flash of Unstyled Text). Either choice impacts &lt;strong&gt;CLS (Cumulative Layout Shift)&lt;/strong&gt; and user experience. This article covers strategies to load fonts reliably while minimizing layout shifts.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-font-display-descriptor"&gt;The font-display Descriptor
&lt;/h2&gt;&lt;p&gt;The &lt;code&gt;font-display&lt;/code&gt; property in &lt;code&gt;@font-face&lt;/code&gt; controls how a font is displayed during loading:&lt;/p&gt;</description></item><item><title>Creative CSS 食譜s with Parent Selector :has()</title><link>https://takao.blog/zh-tw/web/css-has-pseudo-selector-recipes/</link><pubDate>Tue, 10 Mar 2026 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-has-pseudo-selector-recipes/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-has-pseudo-selector-recipes-zh-tw.png" alt="Featured image of post Creative CSS 食譜s with Parent Selector :has()" /&gt;&lt;h2 id="creative-css-recipes-with-parent-selector-has"&gt;Creative CSS Recipes with Parent Selector &lt;code&gt;:has()&lt;/code&gt;
&lt;/h2&gt;&lt;p&gt;For years, CSS developers dreamed of a &lt;strong&gt;parent selector&lt;/strong&gt; — a way to style an element based on its children. JavaScript and extra class names were the only workarounds. Then came &lt;code&gt;:has()&lt;/code&gt;, the CSS pseudo-class that finally makes &amp;ldquo;if this element contains X, style it accordingly&amp;rdquo; a native reality.&lt;/p&gt;
&lt;p&gt;As of 2026, &lt;code&gt;:has()&lt;/code&gt; is 支援 in all major browsers, opening a world of markup simplification and creative styling without touching JavaScript.&lt;/p&gt;</description></item><item><title>Tailwind CSS v4.0 發布與純 CSS 配置</title><link>https://takao.blog/zh-tw/web/tailwind-css-v4-release-changes/</link><pubDate>Thu, 05 Feb 2026 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/tailwind-css-v4-release-changes/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/tailwind-css-v4-release-changes-zh-tw.png" alt="Featured image of post Tailwind CSS v4.0 發布與純 CSS 配置" /&gt;&lt;h2 id="介紹"&gt;介紹
&lt;/h2&gt;&lt;p&gt;Tailwind CSS v4.0 標誌著從基於 JavaScript 的配置到 &lt;strong&gt;CSS 優先架構&lt;/strong&gt; 的範式轉移。 &lt;code&gt;tailwind.config.js&lt;/code&gt; 檔案消失了；設計標記現在使用 &lt;code&gt;@theme&lt;/code&gt; 直接在 CSS 中定義。此版本還整合了 &lt;strong&gt;Lightning CSS&lt;/strong&gt; 以實現極快的構建，採用了 CSS 嵌套和 &lt;code&gt;@layer&lt;/code&gt; 等現代 CSS 功能，並提供了完全重寫的引擎。本文詳細介紹了 v3 的主要變更並提供了實用的遷移指南。&lt;/p&gt;</description></item><item><title>預防ing Cumulative Layout Shift with CSS aspect-ratio</title><link>https://takao.blog/zh-tw/web/css-aspect-ratio-cumulative-layout-shift/</link><pubDate>Wed, 10 Dec 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-aspect-ratio-cumulative-layout-shift/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-aspect-ratio-cumulative-layout-shift-zh-tw.png" alt="Featured image of post 預防ing Cumulative Layout Shift with CSS aspect-ratio" /&gt;&lt;h2 id="understanding-cumulative-layout-shift"&gt;Understanding Cumulative Layout Shift
&lt;/h2&gt;&lt;p&gt;Cumulative Layout Shift (CLS) is one of Google&amp;rsquo;s &lt;strong&gt;Core Web Vitals&lt;/strong&gt; metrics that measures visual stability. It quantifies how often users experience unexpected layout shifts. A high CLS score harms user experience and SEO rankings. The primary cause? Media elements (images, videos, iframes) loading without reserved space.&lt;/p&gt;
&lt;h2 id="how-css-aspect-ratio-works"&gt;How CSS aspect-ratio Works
&lt;/h2&gt;&lt;p&gt;The &lt;code&gt;aspect-ratio&lt;/code&gt; CSS property lets you declare the ratio of width to height for any element. The browser reserves space accordingly, preventing the layout from jumping when content loads.&lt;/p&gt;</description></item><item><title>Implementing 簡單 Dark Mode with CSS light-dark()</title><link>https://takao.blog/zh-tw/web/css-light-dark-color-scheme/</link><pubDate>Fri, 10 Oct 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-light-dark-color-scheme/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-light-dark-color-scheme-zh-tw.png" alt="Featured image of post Implementing 簡單 Dark Mode with CSS light-dark()" /&gt;&lt;h2 id="the-problem-with-traditional-dark-mode"&gt;The Problem with Traditional Dark Mode
&lt;/h2&gt;&lt;p&gt;Implementing dark mode traditionally required duplicate CSS rules wrapped in &lt;code&gt;@media (prefers-color-scheme: dark)&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-css" data-lang="css"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;:&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --bg: &lt;span style="color:#ae81ff"&gt;#ffffff&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --text: &lt;span style="color:#ae81ff"&gt;#111111&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;@&lt;span style="color:#66d9ef"&gt;media&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#f92672"&gt;prefers-color-scheme&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#f92672"&gt;dark&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --bg: &lt;span style="color:#ae81ff"&gt;#1a1a2e&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --text: &lt;span style="color:#ae81ff"&gt;#e0e0e0&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This works but creates maintenance overhead, especially when managing multiple color properties across large stylesheets. The &lt;code&gt;light-dark()&lt;/code&gt; CSS function eliminates this duplication entirely.&lt;/p&gt;
&lt;h2 id="the-light-dark-function"&gt;The light-dark() Function
&lt;/h2&gt;&lt;p&gt;The &lt;code&gt;light-dark()&lt;/code&gt; function 接受 two color values and automatically returns the one matching the user&amp;rsquo;s current color scheme:&lt;/p&gt;</description></item><item><title>沒有預處理器的 CSS 嵌套的標準語法</title><link>https://takao.blog/zh-tw/web/css-nesting-standard-syntax/</link><pubDate>Fri, 15 Aug 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-nesting-standard-syntax/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-nesting-standard-syntax-zh-tw.png" alt="Featured image of post 沒有預處理器的 CSS 嵌套的標準語法" /&gt;&lt;h2 id="介紹"&gt;介紹
&lt;/h2&gt;&lt;p&gt;從歷史上看，編寫巢狀 CSS 規則需要 Sass (SCSS)、Less 或 PostCSS 等預處理工具。&lt;/p&gt;
&lt;p&gt;然而，瀏覽器攤商已經標準化了 &lt;strong&gt;CSS Nesting 規範&lt;/strong&gt;。如今，您可以直接在純 CSS 檔案中編寫巢狀選擇器，並在所有現代 Web 瀏覽器中本機運行它們。&lt;/p&gt;</description></item><item><title>使用 CSS 容器查詢設計模組化佈局</title><link>https://takao.blog/zh-tw/web/css-container-queries-vs-media-queries/</link><pubDate>Thu, 10 Jul 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-container-queries-vs-media-queries/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-container-queries-vs-media-queries-zh-tw.png" alt="Featured image of post 使用 CSS 容器查詢設計模組化佈局" /&gt;&lt;h2 id="介紹"&gt;介紹
&lt;/h2&gt;&lt;p&gt;多年來，&lt;strong&gt;媒體查詢 (&lt;code&gt;@media&lt;/code&gt;)&lt;/strong&gt; 一直是響應式網頁設計的基礎。&lt;/p&gt;
&lt;p&gt;媒體查詢根據瀏覽器視窗的視窗寬度觸發佈局變更。然而，在現代元件驅動開發（使用 React、Vue 或 Web Components）中，基於視窗的樣式元件有明顯的限制。&lt;/p&gt;</description></item><item><title>與 CSS 網格子網格完美對齊</title><link>https://takao.blog/zh-tw/web/css-subgrid-grid-nesting/</link><pubDate>Sat, 10 May 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-subgrid-grid-nesting/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-subgrid-grid-nesting-zh-tw.png" alt="Featured image of post 與 CSS 網格子網格完美對齊" /&gt;&lt;h2 id="介紹"&gt;介紹
&lt;/h2&gt;&lt;p&gt;在卡片佈局中跨列對齊嵌套元件是響應式網頁設計中常見的佈局挑戰。&lt;/p&gt;
&lt;p&gt;雖然 CSS Grid 和 Flexbox 可以輕鬆均衡同級卡片容器的高度，但對齊內部元素（例如標題、正文和 CTA 按鈕）仍然很困難。如果一張卡片具有多行標題，而另一張卡片具有單行標題，則以下元素將錯位，從而導致 UI 不一致。&lt;/p&gt;</description></item><item><title>使用視圖轉換 API 實現平滑頁面轉換</title><link>https://takao.blog/zh-tw/web/css-view-transitions-single-page-api/</link><pubDate>Sat, 05 Apr 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-view-transitions-single-page-api/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-view-transitions-single-page-api-zh-tw.png" alt="Featured image of post 使用視圖轉換 API 實現平滑頁面轉換" /&gt;&lt;h2 id="介紹"&gt;介紹
&lt;/h2&gt;&lt;p&gt;提供動態頁面轉換是提升現代 Web 應用程式整體使用者體驗 (UX) 的關鍵因素。&lt;/p&gt;
&lt;p&gt;從歷史上看，為了在頁面導航之間平滑地變形或淡出元素，開發人員必須導入大量 JavaScript 庫，例如 Framer Motion 或 GAP。這些庫需要深度掛鉤渲染生命週期，以在對舊 DOM 節點進行動畫處理時延遲卸載。&lt;/p&gt;</description></item><item><title>CSS 錨點定位簡介與範例</title><link>https://takao.blog/zh-tw/web/css-anchor-positioning-guide/</link><pubDate>Mon, 10 Feb 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-anchor-positioning-guide/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-anchor-positioning-guide-zh-tw.png" alt="Featured image of post CSS 錨點定位簡介與範例" /&gt;&lt;h2 id="介紹"&gt;介紹
&lt;/h2&gt;&lt;p&gt;在 Web 開發中，相對於特定參考元素（錨點）定位浮動元素（例如工具提示、彈出視窗、下拉式選單和懸停卡）歷來是一項複雜的挑戰。&lt;/p&gt;
&lt;p&gt;為了使浮動元素在視窗大小調整或頁面滾動時跟隨錨點積分，開發人員傳統上依靠連續的 JavaScript 座標計算（使用 &lt;code&gt;getBoundingClientRect()&lt;/code&gt;）來動態更改內聯樣式。因此，像 Popper.js 或 Floating UI 這樣的函式庫成為了業界標準。但是，在滾動事件期間在主執行緒上執行腳本循環經常會導致渲染延遲和卡頓，尤其是在行動裝置上。&lt;/p&gt;</description></item><item><title>CSS Scoped 風格s: @scope and Encapsulation Strategies</title><link>https://takao.blog/zh-tw/web/css-scoped-styles/</link><pubDate>Sun, 15 Dec 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-scoped-styles/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-scoped-styles-zh-tw.png" alt="Featured image of post CSS Scoped 風格s: @scope and Encapsulation Strategies" /&gt;&lt;p&gt;CSS scoping has always been a challenge. Styles cascade globally by default, meaning a selector in one component can unintentionally affect elements in another. Over the years, developers have adopted naming conventions, build-time tools, and full DOM isolation to solve this. The newest addition to this toolkit is the CSS &lt;code&gt;@scope&lt;/code&gt; at-rule, which introduces proximity-based cascade control. This article compares all major scoping strategies and helps you choose the right one.&lt;/p&gt;</description></item><item><title>CSS Trigonometric Functions: Math in Your 風格sheets</title><link>https://takao.blog/zh-tw/web/css-trig-functions/</link><pubDate>Tue, 05 Nov 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-trig-functions/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-trig-functions-zh-tw.png" alt="Featured image of post CSS Trigonometric Functions: Math in Your 風格sheets" /&gt;&lt;p&gt;CSS has evolved from a simple styling language into a powerful computation engine. The introduction of trigonometric functions in CSS Values and Units Module Level 4 &amp;ndash; shipping in Chrome 111+, Firefox 108+, and Safari 15.4+ &amp;ndash; marks a paradigm shift. Developers can now perform geometric calculations directly in stylesheets without preprocessors or JavaScript.&lt;/p&gt;
&lt;h2 id="function-reference-and-syntax"&gt;Function Reference and Syntax
&lt;/h2&gt;&lt;p&gt;Six trigonometric functions are now available in CSS:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Function&lt;/th&gt;
					&lt;th&gt;Input&lt;/th&gt;
					&lt;th&gt;Output&lt;/th&gt;
					&lt;th&gt;Description&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;sin(angle)&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;angle&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt; [-1, 1]&lt;/td&gt;
					&lt;td&gt;Sine of an angle&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;cos(angle)&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;angle&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt; [-1, 1]&lt;/td&gt;
					&lt;td&gt;Cosine of an angle&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;tan(angle)&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;angle&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Tangent of an angle&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;atan2(y, x)&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Arctangent of y/x (full 360°)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;asin(value)&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt; [-1, 1]&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Arcsine&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;acos(value)&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt; [-1, 1]&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Arccosine&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Angle units include &lt;code&gt;deg&lt;/code&gt;, &lt;code&gt;rad&lt;/code&gt;, &lt;code&gt;grad&lt;/code&gt;, and &lt;code&gt;turn&lt;/code&gt;. Common pitfalls include forgetting units, division by zero in &lt;code&gt;atan2&lt;/code&gt;, and domain errors with &lt;code&gt;asin&lt;/code&gt;/&lt;code&gt;acos&lt;/code&gt; inputs outside [-1, 1].&lt;/p&gt;</description></item><item><title>CSS Popover API: Native Overlays 不需要 JavaScript</title><link>https://takao.blog/zh-tw/web/css-popover-api/</link><pubDate>Tue, 20 Aug 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-popover-api/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-popover-api-zh-tw.png" alt="Featured image of post CSS Popover API: Native Overlays 不需要 JavaScript" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Building overlays like tooltips, dropdown menus, and modals has traditionally required a significant amount of JavaScript. Developers have relied on CSS &lt;code&gt;position: absolute&lt;/code&gt; with manual coordinate calculations, ARIA attributes for accessibility, and framework-specific solutions such as React portals or Floating UI. The CSS Popover API changes this by providing a native, declarative way to create overlays that handle positioning, show/hide toggling, focus management, and light dismiss without any JavaScript.&lt;/p&gt;</description></item><item><title>CSS Scroll-Driven Animations: The Future of Scroll-Based 效果</title><link>https://takao.blog/zh-tw/web/css-scroll-driven-animations/</link><pubDate>Tue, 25 Jun 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-scroll-driven-animations/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-scroll-driven-animations-zh-tw.png" alt="Featured image of post CSS Scroll-Driven Animations: The Future of Scroll-Based 效果" /&gt;&lt;h2 id="the-problem-with-javascript-scroll-events"&gt;The Problem with JavaScript Scroll Events
&lt;/h2&gt;&lt;p&gt;Scroll-based effects have traditionally relied on JavaScript scroll event listeners running on the main thread, which often causes jank, dropped frames, and poor user experience. Even with passive listeners and &lt;code&gt;requestAnimationFrame&lt;/code&gt; throttling, layout thrashing remains a persistent issue. CSS Scroll-Driven Animations solve this by moving scroll tracking to the compositor thread, enabling smooth 60fps effects without any JavaScript overhead.&lt;/p&gt;
&lt;h2 id="key-concepts"&gt;Key Concepts
&lt;/h2&gt;&lt;p&gt;Three core concepts power this feature. A &lt;strong&gt;scroll-timeline&lt;/strong&gt; links an animation to the scroll position of a scroll container. A &lt;strong&gt;view-timeline&lt;/strong&gt; ties an animation to an element&amp;rsquo;s visibility within a scroll container. The &lt;strong&gt;animation-timeline&lt;/strong&gt; property binds a named animation to either timeline type. Use &lt;code&gt;timeline-scope&lt;/code&gt; to share timelines across elements in the DOM tree.&lt;/p&gt;</description></item><item><title>CSS @layer：使用層架構管理級聯</title><link>https://takao.blog/zh-tw/web/css-layer-architecture/</link><pubDate>Tue, 11 Jun 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-layer-architecture/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-layer-architecture-zh-tw.png" alt="Featured image of post CSS @layer：使用層架構管理級聯" /&gt;&lt;p&gt;如果您曾經在大型 CSS 專案中經歷過特殊性戰爭 - 覆蓋第三方樣式、散佈 &lt;code&gt;!important&lt;/code&gt; 聲明，或者重組 HTML 只是為了贏得級聯 - &lt;code&gt;@layer&lt;/code&gt; 就是您一直在等待的解決方案。 CSS &lt;code&gt;@layer&lt;/code&gt; at 規則使開發人員能夠明確控制級聯順序，而與特殊性或來源順序無關。&lt;/p&gt;</description></item><item><title>CSS Custom 正確的ties: Strategic Patterns for Scalable 風格s</title><link>https://takao.blog/zh-tw/web/css-custom-properties/</link><pubDate>Tue, 09 Apr 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-custom-properties/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-custom-properties-zh-tw.png" alt="Featured image of post CSS Custom 正確的ties: Strategic Patterns for Scalable 風格s" /&gt;&lt;p&gt;CSS Custom Properties (also known as CSS variables) have fundamentally changed how we write and maintain stylesheets. Unlike preprocessor variables from Sass or Less, custom properties are live, dynamic, and participate in the cascade and inheritance. This article explores strategic patterns for using them in production applications — from design token management to runtime manipulation.&lt;/p&gt;
&lt;h2 id="design-token-management"&gt;Design Token Management
&lt;/h2&gt;&lt;p&gt;Custom properties are the ideal vehicle for design tokens — the atomic values that define a design system&amp;rsquo;s visual language. A well-organized token structure groups colors, spacing, typography, and shadows under a clear naming convention.&lt;/p&gt;</description></item><item><title>CSS Grid 進階 Patterns: Complex Layouts Made 簡單</title><link>https://takao.blog/zh-tw/web/css-grid-advanced/</link><pubDate>Fri, 15 Dec 2023 00:00:00 +0900</pubDate><guid>https://takao.blog/zh-tw/web/css-grid-advanced/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-grid-advanced-zh-tw.png" alt="Featured image of post CSS Grid 進階 Patterns: Complex Layouts Made 簡單" /&gt;&lt;p&gt;CSS Grid has transformed web layout design, but many developers only scratch the surface. Beyond the basic &lt;code&gt;grid-template-columns: 1fr 1fr 1fr&lt;/code&gt; lies a powerful set of features that handle complex, responsive layouts with minimal code. This article explores advanced Grid patterns that every professional front-end developer should know.&lt;/p&gt;
&lt;h2 id="named-grid-areas-for-semantic-layouts"&gt;Named Grid Areas for Semantic Layouts
&lt;/h2&gt;&lt;p&gt;Line-based placement works, but it becomes unreadable as layouts grow complex. Named grid areas let you define layouts that read like a wireframe directly in CSS.&lt;/p&gt;</description></item></channel></rss>