Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh-CN: create Glossary/CLS #23352

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions files/zh-cn/glossary/cls/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: 累计布局偏移(CLS)
slug: Glossary/CLS
l10n:
sourceCommit: fcd4f39485d740615c32ccaef63471bc27095fb0
---

{{GlossarySidebar}}

**累计布局偏移(CLS)**是一种由 Google 设计为[核心 Web 要素](https://web.dev/explore/learn-core-web-vitals)其中之一的网站的可用性指标。
PassionPenguin marked this conversation as resolved.
Show resolved Hide resolved

它可以衡量用户遇到意外布局偏移的程度。这里元素的意外偏移指不是由用户操作(如点按按钮或动画的一部分)引起的偏移。

布局偏移可能是由于未给定 `width` 和 `height` 属性的 {{htmlelement("img")}} 或 {{htmlelement("video")}} 元素引起的,因此浏览器在加载它们之前不知道它们将占用多少空间。

{{domxref("LayoutShift")}} 接口是 [性能 API](/zh-CN/docs/Web/API/Performance_API) 的一部分,可用于测量单个布局偏移,然后用于计算网页的 CLS 分数。
PassionPenguin marked this conversation as resolved.
Show resolved Hide resolved

## 参见

- web.dev 上的 [CLS](https://web.dev/articles/cls)