交互
控制在快照容器内项目周围的滚动偏移的工具。
Class | Styles |
---|---|
scroll-m-<number> | scroll-margin: calc(var(--spacing) * <number>); |
-scroll-m-<number> | scroll-margin: calc(var(--spacing) * -<number>); |
scroll-m-(<custom-property>) | scroll-margin: var(<custom-property>); |
scroll-m-[<value>] | scroll-margin: <value>; |
scroll-mx-<number> | scroll-margin-inline: calc(var(--spacing) * <number>); |
-scroll-mx-<number> | scroll-margin-inline: calc(var(--spacing) * -<number>); |
scroll-mx-(<custom-property>) | scroll-margin-inline: var(<custom-property>); |
scroll-mx-[<value>] | scroll-margin-inline: <value>; |
scroll-my-<number> | scroll-margin-block: calc(var(--spacing) * <number>); |
-scroll-my-<number> | scroll-margin-block: calc(var(--spacing) * -<number>); |
scroll-my-(<custom-property>) | scroll-margin-block: var(<custom-property>); |
scroll-my-[<value>] | scroll-margin-block: <value>; |
scroll-ms-<number> | scroll-margin-inline-start: calc(var(--spacing) * <number>); |
-scroll-ms-<number> | scroll-margin-inline-start: calc(var(--spacing) * -<number>); |
scroll-ms-(<custom-property>) | scroll-margin-inline-start: var(<custom-property>); |
scroll-ms-[<value>] | scroll-margin-inline-start: <value>; |
scroll-me-<number> | scroll-margin-inline-end: calc(var(--spacing) * <number>); |
-scroll-me-<number> | scroll-margin-inline-end: calc(var(--spacing) * -<number>); |
scroll-me-(<custom-property>) | scroll-margin-inline-end: var(<custom-property>); |
scroll-me-[<value>] | scroll-margin-inline-end: <value>; |
scroll-mt-<number> | scroll-margin-top: calc(var(--spacing) * <number>); |
-scroll-mt-<number> | scroll-margin-top: calc(var(--spacing) * -<number>); |
scroll-mt-(<custom-property>) | scroll-margin-top: var(<custom-property>); |
scroll-mt-[<value>] | scroll-margin-top: <value>; |
scroll-mr-<number> | scroll-margin-right: calc(var(--spacing) * <number>); |
-scroll-mr-<number> | scroll-margin-right: calc(var(--spacing) * -<number>); |
scroll-mr-(<custom-property>) | scroll-margin-right: var(<custom-property>); |
scroll-mr-[<value>] | scroll-margin-right: <value>; |
scroll-mb-<number> | scroll-margin-bottom: calc(var(--spacing) * <number>); |
-scroll-mb-<number> | scroll-margin-bottom: calc(var(--spacing) * -<number>); |
scroll-mb-(<custom-property>) | scroll-margin-bottom: var(<custom-property>); |
scroll-mb-[<value>] | scroll-margin-bottom: <value>; |
scroll-ml-<number> | scroll-margin-left: calc(var(--spacing) * <number>); |
-scroll-ml-<number> | scroll-margin-left: calc(var(--spacing) * -<number>); |
scroll-ml-(<custom-property>) | scroll-margin-left: var(<custom-property>); |
scroll-ml-[<value>] | scroll-margin-left: <value>; |
使用 scroll-mt-<number>
、scroll-mr-<number>
、scroll-mb-<number>
和 scroll-ml-<number>
工具,如 scroll-ml-4
和 scroll-mt-6
,设置快照容器内项目周围的滚动偏移:
在图像网格中滚动以查看预期效果
<div class="snap-x ..."> <div class="snap-start scroll-ml-6 ..."> <img src="/img/vacation-01.jpg"/> </div> <div class="snap-start scroll-ml-6 ..."> <img src="/img/vacation-02.jpg"/> </div> <div class="snap-start scroll-ml-6 ..."> <img src="/img/vacation-03.jpg"/> </div> <div class="snap-start scroll-ml-6 ..."> <img src="/img/vacation-04.jpg"/> </div> <div class="snap-start scroll-ml-6 ..."> <img src="/img/vacation-05.jpg"/> </div></div>
要使用负的滚动边距值,可以在类名前加上一个负号:
<div class="snap-start -scroll-ml-6 ..."> <!-- ... --></div>
使用 scroll-ms-<number>
和 scroll-me-<number>
工具设置 scroll-margin-inline-start
和 scroll-margin-inline-end
逻辑属性,这些属性根据文本方向映射到左侧或右侧:
在图像网格中滚动以查看预期效果
从左至右
从右至左
<div dir="ltr"> <div class="snap-x ..."> <div class="snap-start scroll-ms-6 ..."> <img src="/img/vacation-01.jpg"/> </div> <!-- ... --> </div></div><div dir="rtl"> <div class="snap-x ..."> <div class="snap-start scroll-ms-6 ..."> <img src="/img/vacation-01.jpg"/> </div> <!-- ... --> </div></div>
为了获得更好的控制,还可以使用 LTR 和 RTL 修饰符 来根据当前文本方向有条件地应用特定样式。
Use utilities like scroll-ml-[<value>]
and scroll-me-[<value>]
to set the 滚动边距 based on a completely custom value:
<div class="scroll-ml-[24rem] ..."> <!-- ... --></div>
For CSS variables, you can also use the scroll-ml-(<custom-property>)
syntax:
<div class="scroll-ml-(--my-scroll-margin) ..."> <!-- ... --></div>
This is just a shorthand for scroll-ml-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a scroll-margin
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="scroll-m-8 md:scroll-m-0 ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.
The scroll-m-<number>
,scroll-mx-<number>
,scroll-my-<number>
,scroll-ms-<number>
,scroll-me-<number>
,scroll-mt-<number>
,scroll-mr-<number>
,scroll-mb-<number>
, and scroll-ml-<number>
utilities are driven by the --spacing
theme variable, which can be customized in your own theme:
@theme { --spacing: 1px; }
Learn more about customizing the spacing scale in the theme variable documentation.