From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../zh-cn/web/css/scroll-snap-points-y/index.html | 141 +++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 files/zh-cn/web/css/scroll-snap-points-y/index.html (limited to 'files/zh-cn/web/css/scroll-snap-points-y') diff --git a/files/zh-cn/web/css/scroll-snap-points-y/index.html b/files/zh-cn/web/css/scroll-snap-points-y/index.html new file mode 100644 index 0000000000..5e2aa4f4de --- /dev/null +++ b/files/zh-cn/web/css/scroll-snap-points-y/index.html @@ -0,0 +1,141 @@ +--- +title: scroll-snap-points-y +slug: Web/CSS/scroll-snap-points-y +tags: + - CSS + - css snap +translation_of: Web/CSS/scroll-snap-points-y +--- +
{{CSSRef}}{{SeeCompatTable}}{{deprecated_header}}
+ +

摘要

+ +

scroll-snap-points-y CSS属性定义滚动容器中内容的snap点的垂直位置。

+ +

{{cssinfo}}

+ +

语法

+ +
/* 关键值 */
+scroll-snap-points-y: none;
+
+/* 重复的snap点 */
+scroll-snap-points-y: repeat(400px);
+
+/* 全局值 */
+scroll-snap-points-y: inherit;
+scroll-snap-points-y: initial;
+scroll-snap-points-y: unset;
+
+ +

Values

+ +
+
none
+
滚动容器没有定义任何snap点。Elements within the scroll container may still define snap points of behalf of the scroll container.(i don't understand this statement)
+
repeat(<长度>)
+
定义snap点的一个间隔,从容器相关的边缘开始。仅允许正数长度。
+
+ +

正式语法

+ +
{{csssyntax}}
+ +

示例

+ +

HTML内容

+ +
<div id="container">
+  <div>1</div>
+  <div>2</div>
+  <div>3</div>
+</div>
+ +

CSS内容

+ +
#container {
+  height: 200px;
+  width: 220px;
+  overflow-x: hidden;
+  overflow-y: auto;
+  scroll-snap-points-y: repeat(200px);
+  scroll-snap-type: mandatory;
+  font-size: 0;
+}
+
+#container > div {
+  width: 200px;
+  height: 200px;
+  display: inline-block;
+  line-height: 200px;
+  text-align: center;
+  font-size: 100px;
+}
+
+#container > div:nth-child(even) {
+  background-color: #87EA87;
+}
+
+#container > div:nth-child(odd) {
+  background-color: #87CCEA;
+}
+ +

{{EmbedLiveSample("Example", 220, 220)}}

+ +

规范

+ +

此属性曾定义在early draft of CSS Scroll Snap Points Module中,但是后来在in favor of element-based snapping规范中被移出

+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
支持度{{CompatNo}}{{CompatGeckoDesktop("39.0")}}{{CompatNo}}{{CompatNo}}9{{property_prefix("-webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
特性AndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
支持度{{CompatNo}}{{CompatGeckoMobile("39.0") }}[1]{{CompatGeckoMobile("39.0") }}{{CompatNo}}{{CompatNo}}9{{property_prefix("-webkit")}}
+
+ +

[1] 在Firefox移动版上,从内核Gecko 39开始可用,但是低于 layout.css.vertical-text.enabled优先级,默认不可用。

-- cgit v1.2.3-54-g00ecf