Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: 张鑫旭

本书从前端开发人员的需求出发,以“流”为线索,从结构、内容到美化装饰等方面,全面且深入地讲解前端开发人员必须了解和掌握的大量的CSS知识点。同时,作者结合多年的从业经验,通过大量的实战案例,详尽解析CSS的相关知识与常见问题。作者还为本书开发了专门的配套网站,进行实例展示、问题答疑。 作为一本CSS深度学习的书,书中介绍大量许多前端开发人员都不知道的CSS知识点。本书语言通俗易懂,内容深入浅出,并结合实战经验,更适合对CSS有所了解的前端开发人员阅读。通过阅读本书,读者会对CSS世界的深度和广度有一个全新的认识。

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A deep-dive, experience-driven guide to the CSS 2.1 "world," organized around the metaphor of "flow" — ideal for front-end developers who already know CSS basics but want to understand why CSS behaves the way it does and break through a learning plateau. 【Book Arc】 - **Opening (~0%–10%)**: The author explains his 10-year journey and the book's mission — to go beyond CSS manuals and treat CSS as an interconnected "world," not a list of isolated properties. He introduces the core concept of "flow" (流) as the invisible mechanism that governs element layout and positioning, and contrasts CSS 2.1 with the newer, more complex CSS3 world. - **Early (~10%–23%)**: The book establishes essential terminology and the "undefined behavior" concept (browser differences that aren't bugs but unspecified spec areas). It then dives into the two fundamental element types — block-level and inline — and begins dissecting how the "flow" shapes their default behavior, including why list-item elements show bullet markers and how the box model is structured. - **Early–Middle (~23%–42%)**: A detailed exploration of width and height behavior, including the four manifestations of `width:auto` (external vs. internal sizing), the "wrapping" (包裹性) property of inline-block elements, and the "formatting width" of absolutely positioned elements. The author introduces his "no width" principle — letting flow handle horizontal space instead of hard-coding pixel values. - **Middle (~42%–48%)**: The book continues with internal sizing details: minimum content width (min-content), maximum width (max-content), and practical applications like precise scrolling with iScroll. It then transitions into the "box dimension" — how width actually applies to the inner box, comparing it to Earth's structure to explain content, padding, margin, and border relationships. - **Late (~48%–100%)**: Based on the table of contents, the remaining chapters cover inline elements and line-height/vertical-align, float and clear, BFC and overflow, absolute/fixed positioning, z-index and stacking contexts, text handling (font-size, font-family, @font-face, text-indent, etc.), and element decoration (color, borders, backgrounds). These sections apply the flow framework to practical layout and styling challenges. 【Key Takeaways】 - **CSS is a "world," not a manual** (Early): Every property interacts with others — e.g., float behavior is influenced by line-height, font, and cursor. Understanding these interconnections is the key to moving beyond rote memorization; the author explicitly rejects the idea that reading a CSS reference is sufficient. - **"Flow" is the central organizing principle** (Early): Flow is CSS's basic positioning and layout mechanism, analogous to water in the physical world — block elements fill width like water fills a container, inline elements float like wood. Most CSS 2.1 behavior can be understood as flow, its disruption (float, absolute), or its redirection. - **`width:auto` has four distinct behaviors** (Middle): External sizing (block elements fill parent width) vs. internal sizing (shrink-to-fit, minimum content width, and maximum width). Recognizing which applies helps predict layout behavior — e.g., why long unbroken text overflows a container. - **The "no width" principle saves code and maintenance** (Middle): Setting `width:100%` on block elements destroys their natural fluidity, forcing manual recalculation when container sizes change. Letting flow handle horizontal space (with margin/padding auto-allocation) creates self-adaptive layouts. - **"Wrapping" (包裹性) is a key internal-sizing behavior** (Middle): Inline-block elements size to their content but never exceed the container (unless minimum content width is larger). This makes them ideal for mixed text-and-image layouts without layout breakage. - **"Undefined behavior" explains cross-browser quirks** (Early): When browsers differ (e.g., Firefox vs. Chrome on `:active` after `preventDefault()`), it's often not a bug but an unspecified spec area. Understanding this reframes debugging and sets realistic expectations. - **The box model is layered like Earth's structure** (Middle): Width applies to the "inner box," which is composed of multiple parts (content, padding, border, margin). Visualizing this structure clarifies how `box-sizing` and width calculations actually work. 【Reading Tips】 - **Skim the opening chapters (1–2)** if you're already familiar with CSS basics — the "worldview" and terminology sections are motivational and conceptual, but the real value starts with Chapter 3 on flow and element sizing. - **Deep-read Chapter 3** (flow, width/height, box model) — it's the foundation for everything else. Pay special attention to the `width:auto` breakdown and the "no width" principle; these are the book's most actionable insights. - **Use the companion website** (demo.cssworld.cn) for hands-on examples — many concepts (like "wrapping" or minimum width) are much clearer when you see them live. The author references specific demo URLs throughout. - **Treat this as a conceptual companion, not a reference** — the book deliberately skips basic syntax and selectors. Keep a CSS manual handy for property details, but use this book to understand *why* properties behave as they do. - **Expect personal interpretation** — the author admits everything is his own understanding, not official spec. This makes the book readable but means you should verify critical details against current browser behavior, especially since the book targets IE8+ and predates modern CSS. 【Coverage Limits】 This guide synthesizes the opening, early, and middle sections (roughly 0–48% of the book) plus the table of contents. Detailed content on inline elements, float/positioning, stacking contexts, text handling, and decoration (Chapters 5–9) is not covered in the excerpts and is summarized only from the chapter list.
Excerpt 1
.6 简单了解vertical-align上标下标类属性值 5.3.7 无处不在的vertical-align 5.3.8 基于vertical-align属性的水平垂直居中弹框 第6章 流的破坏与保护 6.1 魔鬼属性float 6.1.1 float的本质与特性 6.1.2 float的作用机制 6.1.3...
View in text
Excerpt 2
“此为内联之石,我无法驾驭,你帮我重塑一下。” “小问题!正好,魔法师技能委员会刚通过了我的一个新法术,我给你秀一秀?” “哟,不错啊,快让我瞅瞅!” “好嘞!”只见 display 拿出自己的法器,念道:“类名之石, test 为名,为我选择,出!”紧接着,“层叠天星,幻化有形,flex,变!” 只听见一声清脆...
View in text
Excerpt 3
就把它们分为两类: 块级元素 (block-level element)和 内联元素 (inline element)。 注意,如果按照W3C的CSS规范区分,这里应该分为“块级元素”和“内联级元素” (inline-level element)。但是,在W3C的HTML4规范中,已经明确把HTML元素分成了“块...
View in text
Excerpt 4
凡事发生必有缘由。CSS世界的造物主为何要设计“包裹性”这个东西呢?是为谁设计的呢? 反问是探究知识的很好的习惯和方式。要回答上面的问题,我们只要请一个嘉宾出来,答案就基本差不多了。下面我们就请出重量级嘉宾——著名的“按钮”元素。没错,就是默认长得比较丑,样式定义兼容性又不好的按钮元素。 按钮通常以如下两种形式出...
View in text
Excerpt 5
我们似乎找到了解决问题的钥匙,自从用了 box-sizing ,标签层级少了,错位问题不见了,一口气写5张页面,不费劲。 实际上,当遭遇类似图3-23所示的布局时,你会发现, box-sizing 也是捉襟见肘,因为边框外的间距只能是 margin ,但 box-sizing 并不支持 margin-box ,若...
View in text
Excerpt 6
h/max-width 就没有任何出现的价值,因为它们是具有边界行为的属性,所以没有变化自然无法触发,也就没有使用价值。 因此,新人并不会经常使用 min-width/max-width ,只有随着CSS技能深入,能够兼顾还原性的同时还兼顾扩展性和适配性之后, min-width/max-width 才会用得越来...
View in text
Excerpt 7
00像素× 150像素,结果不仅不是这个尺寸,而且各个浏览器下的尺寸还不一样。IE浏览器下是28×30,如图4-2所示。Chrome浏览器下是0×0,如图4-3所示。Firefox浏览器下显示的是0×22,如图4-4所示。 图4-2 IE浏览器图片默认尺寸 图4-3 Chrome浏览器图片默认尺寸 图4-4 Fi...
View in text
Excerpt 8
显示了,如图4-11所示,且各种表现都符合替换元素,如尺寸规则,或者不支持 ::before/::after 伪元素等。 图4-11  content 属性直接生成图片演示截图 另外还有一点很有意思,如果图片原来是有 src 地址的,我们也是可以使用 content 属性把图片内容给置换掉的,于是,我们就能轻松实...
View in text
Tags
AI categories
Web Technologycssfrontend
Publish Year: 2017
Language: Chinese
File Format: EPUB
File Size: 4.3 MB