
语言 🇨🇳 简体中文
入门指南
小部件样式
其他前端库
自定义样式指南
本指南提供 FastComments 评论小部件 (v2) 使用的完整默认 CSS 以及一些说明 用于覆盖这些样式。
了解默认 CSS 可让您:
- 自定义外观,通过覆盖特定样式
- 排查样式问题,查看有哪些类和选择器可用
- 构建自定义主题,使其适配小部件的结构
- 与 AI 助手配合使用,生成自定义 CSS 修改。
如何覆盖样式
覆盖样式的方法取决于小部件。对于评论小部件,您必须使用 customCSS 配置参数将 CSS 传入 iframe,或者在管理面板的自定义页面中指定 CSS,该页面会从我们的 CDN 提供该 CSS。
如何自定义样式 
如何自定义评论小部件样式
您可以通过两种方式自定义评论小部件的样式:
选项 1:通过 customCSS 参数
在初始化小部件时,将自定义 CSS 作为字符串传递给 customCSS 参数:
window.fcConfigs = [{
target: '#fastcomments-widget',
tenantId: 'your-tenant-id',
customCSS: `
.fast-comments .comment {
background-color: #f0f0f0 !important;
border-radius: 8px !important;
}
`
}];
选项 2:通过管理仪表板
- 在管理仪表板中转到 小部件自定义页面
- 向下滚动到 "Advanced" 下的 "Custom CSS" 部分
- 输入您的自定义 CSS
- 点击 "Save"
您的自定义 CSS 将应用到您网站上的所有评论小部件。
提示
- 如有需要,使用
!important覆盖默认样式 - 针对特定选择器,以免影响站点的其他部分
- 在不同浏览器中测试您的 CSS 以确保兼容性
- 该小部件使用标准 CSS —— 不需要特殊的预处理器
自定义评论框边框 
The border around the comment box is made of the text area's own border plus a few thin lines the widget draws around it. To change its color or corner roundness, set these CSS variables instead of styling the textarea directly. The variables restyle every part of the border at once, so the corners and colors always line up.
| 变量 | 更改内容 | 默认 |
|---|---|---|
--fc-input-border-color | 边框颜色 | #bfbfbf |
--fc-input-border-color-focus | 用户输入时的边框颜色 | #555 |
--fc-input-border-radius | 圆角的圆润程度 | 11px |
--fc-input-border-start-start-radius | 方形左上角(在从右到左的语言中为右上角)的圆润程度 | 0 |
Add the CSS to the 自定义 CSS box on the Widget Customization page, or pass it with the customCSS option. You only need to set the variables you want to change.
You can also use the Comment box border helper right under the Custom CSS box, which writes this CSS for you.
更改边框颜色

更改输入时的边框颜色

圆化四个角
By default the top-left corner is square. Set both radius variables to round all four corners the same:

方形角

匹配品牌风格

暗模式下的不同颜色
When the widget is in dark mode it has the dark class, so you can set different values for dark mode:

为什么不直接为文本区域设置样式?
The widget draws part of the comment box border itself, around the text area. If you set border-color or border-radius only on the textarea, those lines keep the default style and the border looks mismatched, for example a square line running through a rounded corner. The variables above change both at once.
评论小部件自定义 CSS 参考(第2版,最新) 

最近评论小部件样式 
最新评论小部件显示您站点上或特定页面的最新评论列表。它包括标题、圆形头像、评论预览、可点击的日期(可深度链接到评论),并能自动检测暗色模式。
基本安装
Run 
配置选项
- tenantId (required): Your FastComments tenant ID
- urlId (optional): Filter to a single page. Leave null for all pages
- count (optional): Number of comments to show. Default is
10 - hasDarkBackground (optional): Force dark mode styling. Auto-detected from the page background if not set
小部件结构
小部件将渲染为以下 HTML 结构:

默认 CSS 参考

自定义示例
更改头像大小

显示更多评论行

移除容器边框

讨论最多页面小部件样式 
最受讨论页面小部件显示您被评论次数最多页面的排名列表。它包括标题、编号排名、带图标的评论计数、最后活动日期,以及自动暗色模式检测。
基本安装
Run 
配置选项
- tenantId (required): Your FastComments tenant ID
- hasDarkBackground (optional): Force dark mode styling. Auto-detected from the page background if not set
小部件结构
该小部件使用以下 HTML 结构进行渲染:

默认 CSS 参考

自定义示例
移除排名徽章

移除容器边框

最近讨论小部件样式 
The Recent Discussions Widget displays a list of pages sorted by the most recent comment activity. It includes a heading, last activity dates, comment counts with icons, and automatic dark mode detection.
Basic Installation
Run 
Configuration Options
- tenantId (required): 您的 FastComments 租户 ID
- count (optional): 要显示的页面数量。默认值为
20,最大100 - hasDarkBackground (optional): 强制暗模式样式。如果未设置,将自动从页面背景检测
Widget Structure
The widget renders with the following HTML structure:

Default CSS Reference

Customization Examples
Remove the Container Border

Custom Link Color
