国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Specification Gaps
Historical Browser Inconsistencies
Readability and Scrolling Concerns
A Quick Review of Properties and Values
Enhanced Relevance in Modern CSS
Practical Application: A Responsive Article Layout
Addressing Past Limitations
A Renewed Perspective on Multi-Column Layout
Home Web Front-end CSS Tutorial Revisiting CSS Multi-Column Layout

Revisiting CSS Multi-Column Layout

Mar 07, 2025 pm 04:58 PM

Revisiting CSS Multi-Column Layout

Nearly two decades have passed since my first book, Transcending CSS, explored the then-novel Multi-Column Layout module. An updated, freely available online version, Transcending CSS Revisited, offers a contemporary perspective. My background in print likely fueled my initial enthusiasm for this CSS feature, enabling columnar content without superfluous markup. Despite its consistent use in my work, CSS Columns remains surprisingly underutilized. Why?

Specification Gaps

Multi-Column Layout has long suffered from, and continues to have, significant limitations. As Rachel Andrew (now a specification editor) highlighted five years ago: direct styling of individual column boxes isn't possible; JavaScript manipulation or adjustments to background, padding, and margins are unavailable; and all columns remain uniformly sized. Only column rules offer styling options.

This remains true. Selective styling, such as alternating background colors using :nth-column(), is impossible. While column rules allow for border-style variations (dashed, dotted, solid, groove, ridge), the absence of border-image support is puzzling, given their near-simultaneous introduction. These imperfections exist, but they don't fully explain the widespread neglect of this valuable tool.

Historical Browser Inconsistencies

Older browsers often ignored unsupported column properties. However, the early adoption of Multi-Column Layout coincided with a period where cross-browser consistency wasn't a paramount concern for many developers. While initial browser support was inconsistent, particularly regarding content breaks, modern browsers now offer widespread compatibility. Yet, the perception of CSS Columns as "broken" persists among developers I've spoken with. While improvements are needed, this shouldn't hinder the use of its currently functional aspects.

Readability and Scrolling Concerns

The underutilization of Multi-Column Layout might stem not from specification flaws or implementation issues, but from usability challenges. Rachel Andrew correctly pointed out the potential for poor readability due to excessive vertical scrolling in long-form content. This is undeniably a negative reading experience.

Careful consideration is crucial, but this shouldn't be a deterrent. Poor design choices, such as inappropriately applying columns to large amounts of text without structural elements, are the true culprits. Headings, images, and quotes can effectively span columns, improving readability. Combined with container queries and modern text sizing units, there's little reason to avoid Multi-Column Layout.

A Quick Review of Properties and Values

Two primary methods exist for creating columns: specifying the column-count or defining the column-width, letting the browser determine the column count. I prefer column-width, setting a width (e.g., 18rem) and letting the browser optimize the number of columns.

The column-gap (gutter) controls spacing between columns, ideally using rem units for text size proportionality. The column-rule adds visual separation with customizable thickness and border-style. This straightforward syntax contributes to its ease of use.

Enhanced Relevance in Modern CSS

At the time of Transcending CSS, many modern CSS features were absent: rem and viewport units, advanced selectors like :has(), container queries, media queries for responsive design, calc(), clamp(), CSS Grid, and Flexbox. These advancements enhance Multi-Column Layout's capabilities.

rem and viewport units, coupled with calc() and clamp(), enable responsive text sizing within columns. :has() allows conditional column creation based on content. Container queries enable column implementation only when sufficient container space is available. Integration with CSS Grid or Flexbox unlocks even more creative layouts.

Practical Application: A Responsive Article Layout

My challenge was creating a flexible, media-query-free article layout adapting to screen size and the presence/absence of a <figure></figure>. Columnar text improves readability, with text size adjusting to container width, not viewport width.

The HTML is simple: a <main></main> element containing a heading and paragraphs, and optionally a <figure></figure>.

<main><h1>About Patty</h1>
<p>…</p></main><img  alt="Revisiting CSS Multi-Column Layout" >

Multi-Column Layout styles are applied to <main></main> using column-width (40ch), max-width (100ch), and automatic margins for centering:

main {
  margin-inline: auto;
  max-width: 100ch;
  column-width: 40ch;
  column-gap: 3rem;
  column-rule: .5px solid #98838F;
}

Flexbox is applied to <section></section> only if it contains a <figure></figure>:

section:has(> figure) {
  display: flex;
  flex-wrap: wrap;
  gap: 0 3rem;
}

min-width: min(100%, 30rem) ensures responsiveness for both <main></main> and <figure></figure>:

section:has(> figure) main {
  flex: 1;
  margin-inline: 0;
  min-width: min(100%, 30rem);
}

section:has(> figure) figure {
  flex: 4;
  min-width: min(100%, 30rem);
}

This eliminates the need for media queries. Text size adapts using container queries (container-type: inline-size;) and clamp() for responsive scaling:

h1 { font-size: clamp(5.6526rem, 5.4068rem + 1.2288cqi, 6.3592rem); }
h2 { font-size: clamp(1.9994rem, 1.9125rem + 0.4347cqi, 2.2493rem); }
p { font-size: clamp(1rem, 0.9565rem + 0.2174cqi, 1.125rem); }

The result is a flexible layout adapting to screen size and content, utilizing Multi-Column Layout effectively.

Addressing Past Limitations

Many articles highlight Multi-Column Layout's flaws, particularly scrolling issues. The column-span property (for headings, images, quotes to span columns) significantly mitigates this, along with careful content design to minimize excessive scrolling.

Orphaned headings and figures are addressed using break-after: column;.

A Renewed Perspective on Multi-Column Layout

Despite its age and past limitations, Multi-Column Layout remains underutilized. While challenges exist, its value and ability to enhance design remain. It's time for a fresh look at this powerful CSS tool.

The above is the detailed content of Revisiting CSS Multi-Column Layout. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is 'render-blocking CSS'? What is 'render-blocking CSS'? Jun 24, 2025 am 12:42 AM

CSS blocks page rendering because browsers view inline and external CSS as key resources by default, especially with imported stylesheets, header large amounts of inline CSS, and unoptimized media query styles. 1. Extract critical CSS and embed it into HTML; 2. Delay loading non-critical CSS through JavaScript; 3. Use media attributes to optimize loading such as print styles; 4. Compress and merge CSS to reduce requests. It is recommended to use tools to extract key CSS, combine rel="preload" asynchronous loading, and use media delayed loading reasonably to avoid excessive splitting and complex script control.

External vs. Internal CSS: What's the Best Approach? External vs. Internal CSS: What's the Best Approach? Jun 20, 2025 am 12:45 AM

ThebestapproachforCSSdependsontheproject'sspecificneeds.Forlargerprojects,externalCSSisbetterduetomaintainabilityandreusability;forsmallerprojectsorsingle-pageapplications,internalCSSmightbemoresuitable.It'scrucialtobalanceprojectsize,performanceneed

What is Autoprefixer and how does it work? What is Autoprefixer and how does it work? Jul 02, 2025 am 01:15 AM

Autoprefixer is a tool that automatically adds vendor prefixes to CSS attributes based on the target browser scope. 1. It solves the problem of manually maintaining prefixes with errors; 2. Work through the PostCSS plug-in form, parse CSS, analyze attributes that need to be prefixed, and generate code according to configuration; 3. The usage steps include installing plug-ins, setting browserslist, and enabling them in the build process; 4. Notes include not manually adding prefixes, keeping configuration updates, prefixes not all attributes, and it is recommended to use them with the preprocessor.

CSS Case Sensitivity: Understanding What Matters CSS Case Sensitivity: Understanding What Matters Jun 20, 2025 am 12:09 AM

CSSismostlycase-insensitive,butURLsandfontfamilynamesarecase-sensitive.1)Propertiesandvalueslikecolor:red;arenotcase-sensitive.2)URLsmustmatchtheserver'scase,e.g.,/images/Logo.png.3)Fontfamilynameslike'OpenSans'mustbeexact.

What is the conic-gradient() function? What is the conic-gradient() function? Jul 01, 2025 am 01:16 AM

Theconic-gradient()functioninCSScreatescirculargradientsthatrotatecolorstopsaroundacentralpoint.1.Itisidealforpiecharts,progressindicators,colorwheels,anddecorativebackgrounds.2.Itworksbydefiningcolorstopsatspecificangles,optionallystartingfromadefin

CSS tutorial for creating a sticky header or footer CSS tutorial for creating a sticky header or footer Jul 02, 2025 am 01:04 AM

TocreatestickyheadersandfooterswithCSS,useposition:stickyforheaderswithtopvalueandz-index,ensuringparentcontainersdon’trestrictit.1.Forstickyheaders:setposition:sticky,top:0,z-index,andbackgroundcolor.2.Forstickyfooters,betteruseposition:fixedwithbot

What is the scope of a CSS Custom Property? What is the scope of a CSS Custom Property? Jun 25, 2025 am 12:16 AM

The scope of CSS custom properties depends on the context of their declaration, global variables are usually defined in :root, while local variables are defined within a specific selector for componentization and isolation of styles. For example, variables defined in the .card class are only available for elements that match the class and their children. Best practices include: 1. Use: root to define global variables such as topic color; 2. Define local variables inside the component to implement encapsulation; 3. Avoid repeatedly declaring the same variable; 4. Pay attention to the coverage problems that may be caused by selector specificity. Additionally, CSS variables are case sensitive and should be defined before use to avoid errors. If the variable is undefined or the reference fails, the fallback value or default value initial will be used. Debug can be done through the browser developer

Unlock the Potential of CSS Animations: A Deep Dive Unlock the Potential of CSS Animations: A Deep Dive Jun 20, 2025 am 12:14 AM

CSSanimationsenhancewebpagesbyimprovinguserexperienceandsitefunctionality.1)Usetransitionsforsmoothstylechanges,asinthebuttoncolorexample.2)Employkeyframesfordetailedanimations,likethebouncingball.3)Ensureperformancebykeepinganimationssimpleandusingt

See all articles