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

推荐订阅源

MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
博客园 - 叶小钗
A
About on SuperTechFans
Last Week in AI
Last Week in AI
量子位
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
Vercel News
Vercel News
博客园 - 司徒正美
博客园 - Franky
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
J
Java Code Geeks

CloudCannon Blog

Building with AI: Git-based vs headless vs traditional CMS CloudCannon + Astro: performance meets powerful content management Introducing the Astro Component Starter Introducing Jetstream — built on the Astro Component Starter Why we switched to the system font stack Redesigning CloudCannon’s docs with Diátaxis, Lume, and Pagefind Make content editing more visual: upgraded Editable Regions How Configuration Mode makes building editing interfaces easy Your hosting just got an upgrade (and a price cut) Custom testing domains for professional branding Keep your content consistent with input validation Managing multilingual content in CloudCannon Simplify team publishing with conflict resolution and domain tools Open Beta: Publishing Conflict Resolution Getting started with CloudCannon and Astro: Bookshop, components, and live editing Welcome to the CloudCannon Community! Omnichannel delivery is just marketing spin from API-based CMS companies Getting started with CloudCannon and Astro: Snippets and Collections Managing digital assets in CloudCannon: a guide to smart asset storage Understanding CloudCannon's branching workflows and Projects: a complete guide What is a static website? CloudCannon’s 2024 wrapped Getting started with CloudCannon and Astro: WYSIWYG blogging Jamstack vs. WordPress: reasons to make the change The top five static site generators for 2025 (and when to use them!) Free Jekyll themes for 2025: ten great community options Eleventy (11ty) vs. Hugo How to set up WYSIWYG editing with MkDocs Material The rise of static-first websites: why major brands are making the switch Watching your Core Web Vitals on Jamstack
New web component for responsive HTML tables
2023-11-02 · via CloudCannon Blog

When you're adding a large table to your website, a common problem that you'll see is content either getting clipped or overflowing horizontally. It can happen when you have a small viewport of that table and the table attempts to render on that small view.

We have a nice, easy solution for this — a new web component called <table-saw>, which detects your viewport and renders the table accordingly. The full repo is available at https://github.com/zachleat/table-saw/; you can also check out a container query example of this on https://zachleat.github.io/table-saw/demo.html

As you’ll see in the demo, if we resize this container, it will re-render the table in a two column layout, repeating the table headers and pairing them up with every single cell in the body of the table.

We’ve already deployed it live to the CloudCannon website. Depending on your viewport size, you’ll see either the original tables rendering or a two-column layout; we’ve set a specific breakpoint for that swap.

Within the CloudCannon CMS, any content author can easily add this responsive table to their own page or blog post, just by adding a Snippet (a.k.a. an Eleventy shortcode). This will lets editors build tables with a familiar table layout, with inline editing of the headers and data cells.

How to add responsive tables on CloudCannon Direct link to this section

To add <table-saw> as a Snippet on CloudCannon with our Bookshop component management system, I’ve added the tablesaw.bookshop.yml and tablesaw.eleventy.liquid files to our markdown component library: these establish the parameters of the component and define its structure, as well as calling the table-saw.js script and styling the table itself.

# Metadata about this component, to be used in the CMS
spec:
label: "Responsive Table"
description:
icon: table
tags: []

# Defines the structure of this component, as well as the default values
blueprint:
content_markdown: ""

# Overrides any fields in the blueprint when viewing this component in the component browser
preview:

# Any extra CloudCannon inputs configuration to apply to the blueprint
_inputs:

<script type="module" src="/js/table-saw.js"></script>
<div><table-saw zero-padding text-align>{{ content_markdown }}</table-saw></div>

In order to access the new ‘Responsive Table’ Snippet in the toolbar, I’ve also added the following under _snippets in my cloudcannon.config.yml file:

tablesaw:
template: eleventy_liquid_bookshop_component
inline: false
preview:
text: Responsive Table
definitions:
component_name: markdown/tablesaw
named_args:
- editor_key: content_markdown
type: string

Installing the responsive tables component for local development Direct link to this section

You have a few options to install table-saw:

  1. Install via npmnpm install @zachleat/table-saw
  2. Download the source manually from GitHub into your project.
  3. Skip this step and use the script directly via a third-party CDN (not recommended for production use)