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

推荐订阅源

V2EX - 技术
V2EX - 技术
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
S
Securelist
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
量子位
博客园 - Franky
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
T
Troy Hunt's Blog
N
News | PayPal Newsroom
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
小众软件
小众软件
P
Palo Alto Networks Blog
Spread Privacy
Spread Privacy
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
L
LINUX DO - 最新话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
P
Privacy International News Feed
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
博客园_首页
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
D
DataBreaches.Net
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
Engineering at Meta
Engineering at Meta
Forbes - Security
Forbes - Security
T
Tenable Blog

Example blog

Ghost routing explained with routes.yaml examples — routes, collections & taxonomies Ghost redirects explained with practical redirects.yaml examples How to Serve JSON or XML Data in Ghost How to Change Your Default Post Template in Ghost Ghost Custom Theme Settings How to add Google Fonts to Ghost Themes How to Configure Ghost with Mailgun Ghost Theme Structure & Organization How to Make Custom Templates in Ghost Themes How to Install Ghost CMS via Ghost-CLI How to Add Syntax Highlighting to Ghost The best Ghost CMS hosting platforms Ghost 6.0 — Social Web and Native Ghost Analytics Ghost CMS Social web beta, email 2FA and more author social links How to keep custom design settings when updating your Ghost theme How to use the public preview card in Ghost How to add members-specific sections in Ghost How to customize the default content CTA in Ghost How to build a custom homepage in Ghost An overview of Ghost editor cards and and how they work Ghost CMS News: One-time payments & collecting sales tax How to customize the private site access template in Ghost How to add custom fonts in Ghost themes Ghost CMS News: Additional payment methods & internal linking How to use Code Injection in Ghost How to set meta data of your custom routes & collections in Ghost Ghost CMS News: TK reminders, ActivityPub and improvements How to format dates and use the date helper in Ghost Ghost CMS internationalization, custom fonts & spam protection Understanding and optimizing post and page settings in Ghost CMS Trigger the Ghost Portal popup based on page scroll progress How to Deploy Your Ghost Theme with GitHub Actions How to create a custom recommendations page for your Ghost CMS theme Ghost CMS News: New editor, refreshed settings & recommendations Ghost CMS News: Source - the new default theme and native image editing How to Add Different Logos for Dark & Light Themes in Ghost Upgrade to Node v18 for Ghost CMS & common errors Ghost Snippets: Adding Schema markup in Ghost How to add a scroll-based progress bar to your Ghost CMS site How to Create a Custom Navigation Template in Ghost How to Segment Subscribers with Member Labels in Ghost The best way to create a contact page in Ghost How to Use the Ghost Subscription Forms in Your Theme & Posts How to update your Ghost site URL when self-hosting Ghost CMS News: Signup cards and better landing pages How to Add Breadcrumbs to Your Ghost Theme How to integrate the Applause Button into your Ghost theme How to Hide a Post From the Home Page in Ghost CMS Ghost CMS block and contentFor helper overview & tips How to add Image Lightbox to Ghost Themes Ghost CMS News: Signup form embed, new editor and bulk actions. Biron Themes becomes Bright Themes 🎉 How to Audit & Test a Ghost Theme How to Create Related Posts Section in Ghost How to Use Ghost Filter Expressions Ghost CMS newsletter settings and post analytics How to Update Your Ghost Theme When We Release New Versions Ghost CMS News: Automatic list cleaning & email troubleshooting How to Create a Featured Post Slider in Ghost How to Add Reading Time to Ghost Blog Posts How to Create a Post Archive for Your Ghost Theme Ghost CMS Price Helper Overview & Tips Self-Hosted Ghost CMS with DigitalOcean Ghost CMS News: Member Growth Sources & Audience Feedback How to Open External Links in a New Tab in Ghost How to Integrate Google Analytics with Ghost Ghost CMS News: History Log & Newsletter Analytics How to Automatically Add Member Labels From Referral Traffic in Ghost? Ghost CMS News: Free trials & email notifications Ghost CMS Match Helper Usage & Tips Ghost CMS News: Native Comments Ghost CMS News: Ghost Explore & Premium Newsletter Previews Ghost Snippets: Custom Progress Cards & Steps Ghost CMS News: Native Search The Best Ghost CMS Search Plugins & Libraries How to Add a Scroll Top & Progress Indicator Button in Ghost Ghost Snippets: Accordions How to Add Tag Dropdown to Your Ghost Theme Ghost 5.0 released 🎉 Ghost Snippets: Custom Subscribe Forms Ghost Snippets: Custom Alert Boxes How to Show Post or Newsletter Issue Number in Ghost How to Self-Host Google Fonts in Ghost CMS Ghost CMS News: Membership, Tiers & Activity Feed Custom Pages in Ghost CMS Themes Ghost CMS Search Using Fuse.js Ghost CMS News: Offers and Discounts & New Cards Ghost CMS News: Membership tiers, email CTA & filters Ghost CMS News: Grammarly Support & Feature Image Captions. Ghost CMS News: Improved Member Accounts & Personalized Newsletter. Ghost 4.0 Launched With Native Newsletters & Membership Ghost CMS News: Cancellation Feedback & Newsletter Stats. Ghost CMS News: Improved Member Dashboard & Sidebar Views. Ghost CMS News: Google Pay support, email newsletters & secondary navigation Ghost CMS News: Member Support, Portal & Content Snippets. Ghost CMS News: Referral Programs & Responsive Images. Ghost Themes as Progressive Web Apps Ghost 3.0 is here with brand new features Ghost 2.0 is here with new features How to Add Search to Ghost Using ghostHunter
Ghost Snippets: Custom Stylish Tables
Bright Themes · 2022-07-10 · via Example blog

The HTML table is used for arranging data into the tabular design. Tables consist of rows and columns and are often used on websites for the effective displaying of tabular data.

A table in HTML makes a lot of sense when you want to organize data that would look best in a spreadsheet. An HTML table is a great way to display things such as financial data, calendars, pricing, feature comparison, the nutrition facts information panel, bowling scores, and many other tabular data.

Tables semantically indicate tabular data and they are the best choice for displaying data of this kind.

Table elements & markup

A table in HTML basically consists of table cells inside rows and columns:

  • <td>(table data) - Each table cell is defined by a <td> and a </td> tag.
  • <tr>(table row) - Each table row starts with a <tr> and end with a </tr> tag.
  • <th>(table header) - Sometimes you want your cells to be headers, in those cases use the <th> tag instead of the <td> tag.
  • <thead> - The <thead> tag is used to group header content in an HTML table.
  • <tbody> - The <tbody> tag is used to group the body content in an HTML table.

Now that we have the basics, let's create an HTML card in the editor with the following markup. Here is the code that you can paste directly in the HTML card:

<table class="table-comparison tbody-bg-odd">
  <thead>
    <tr>
      <th></th>
      <th>Basic</th>
      <th>Standard</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>All limited links</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>Own analytics platform</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>Chat support</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>Optimize hashtags</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>Unlimited</td>
      <td></td>
      <td></td>
    </tr>
    </tr>
  </tbody>
</table>

A second example:

<table class="table-comparison tbody-bg-odd">
  <thead>
    <tr>
      <th></th>
      <th>iPhone 13</th>
      <th>Samsung S21</th>
      <th>Xiaomi 11</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Price</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
    <tr>
      <td>Diplay size</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
    <tr>
      <td>RAM</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
    <tr>
      <td>Resolution</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
    <tr>
      <td>Processor</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
    <tr>
      <td>Camera</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
    <tr>
      <td>Battery</td>
      <td>
        <span class="good">GOOD</span>
      </td>
      <td>
        <span class="mid">MID</span>
      </td>
      <td>
        <span class="bad">BAD</span>
      </td>
    </tr>
  </tbody>
</table>

Table styling

Let's start styling our tables. The complete CSS is available and can be pasted in Code Injection in the Ghost Admin:

.table-comparison {
  margin-bottom: 4em;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  overflow: hidden;
  display: inline-block;
  overflow-x: auto;
}

.table-comparison thead {
  background-color: none;
}

.table-comparison th {
  padding: 0.5em 1em;
}

.table-comparison td {
  text-align: center;
  padding: 0.5em 1em;
}

.table-comparison td:first-child {
  text-align: left;
}

.tbody-bg-odd tbody tr:nth-child(odd) {
  background-color: #f2f2f2;
}

.tbody-bg-even thead tr:nth-child(odd) {
  background-color: #f2f2f2;
}

.table-comparison tbody .success {
  display: flex;
  background-color: #1fcc82;
  width: 24px;
  height: 24px;
  position: relative;
  border-radius: 50%;
}

.table-comparison tbody .success::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 10px;
  display: inline-block;
  width: 3px;
  height: 8px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}

.table-comparison tbody .cancel {
  display: flex;
  background-color: #ff3b3b;
  width: 24px;
  height: 24px;
  position: relative;
  border-radius: 50%;
}

.table-comparison tbody .cancel::before,
.cancel::after {
  position: absolute;
  top: 11px;
  bottom: 0;
  left: 6.3px;
  right: 0;
  content: '';
  background-color: #fff;
  width: 11px;
  height: 2px;
  border-radius: 2px;
}

.table-comparison tbody .cancel::before {
  transform: rotate(-45deg);
}

.table-comparison tbody .cancel::after {
  transform: rotate(45deg);
}

.table-comparison tbody .mid {
  --color-accent: #fbc103;
  color: var(--color-accent);
  border-radius: 2rem;
  padding: 0.2em 1em;
  font-size: 0.8rem;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  font-weight: 700;
}

.table-comparison tbody .mid::before {
  background-color: var(--color-accent);
  opacity: 0.2;
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.table-comparison tbody .good {
  --color-accent: #16c60c;
  color: var(--color-accent);
  border-radius: 2rem;
  padding: 0.2em 1em;
  font-size: 0.8rem;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  font-weight: 700;
}

.table-comparison tbody .good::before {
  background-color: var(--color-accent);
  opacity: 0.2;
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.table-comparison tbody .bad {
  --color-accent: #f03a17;
  color: var(--color-accent);
  border-radius: 2rem;
  padding: 0.2em 1em;
  font-size: 0.8rem;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  font-weight: 700;
}

.table-comparison tbody .bad::before {
  background-color: var(--color-accent);
  opacity: 0.2;
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

The rendered tables

Here is the final look of the tables:

Ghost CMS Table
Ghost CMS Table
Ghost CMS Table
Ghost CMS Table

You can customize the appearance of the tables, by changing the CSS.

Creating a snippet out of the markup will make it easy to include it anywhere in your posts.