35 lines
1.0 KiB
CSS
35 lines
1.0 KiB
CSS
*{
|
||
/* 初始化 */
|
||
margin: 0;
|
||
padding: 0;
|
||
}
|
||
.container{
|
||
/* 100%窗口宽度和高度 */
|
||
width: 100vw;
|
||
height: 100vh;
|
||
/* 弹性布局 */
|
||
display: flex;
|
||
/* 设置滚动贴合的方式:沿X轴滚动 mandatory表示强制滚动 */
|
||
scroll-snap-type: x mandatory;
|
||
/* 需要把滚动条设置到直接父容器,scroll-snap-type才能生效 */
|
||
/* 溢出时,水平保留滚动条,垂直隐藏滚动条 */
|
||
overflow-x: scroll;
|
||
overflow-y: hidden;
|
||
}
|
||
.container div{
|
||
/* 100%窗口宽度和高度 */
|
||
width: 100vw;
|
||
height: 100vh;
|
||
/* 弹性布局 居中 */
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
/* 通过var函数调用自定义属性--c,设置各个div的背景颜色 */
|
||
background-color: var(--c);
|
||
font-size: 200px;
|
||
color: #fff;
|
||
/* 设置下一页的内容会滚动贴合到顶部 */
|
||
scroll-snap-align: start;
|
||
/* 在flex容器中,当空间不够时,元素会被挤压,flex-shrink为0可以防止元素被挤压 */
|
||
flex-shrink: 0;
|
||
} |