当前位置:网站首页>After the element uses align items center and overflow auto, some contents are not fully displayed
After the element uses align items center and overflow auto, some contents are not fully displayed
2022-06-30 00:39:00 【Zheng One Dream】
When we use to center the content align-items center After the attributes , Because the small screen will block part of the content
We'll add... To the box overflow-y auto This attribute
But when we zoom out , Will find , The top half of the content will not be displayed
<style>
.box {
height: 100vh;
display: flex;
align-items: center;
overflow-y: auto;
}
.content {
height: 600px;
}
</style>
<body>
<div class="box">
<div class="content"></div>
</div>
</body>This is because the element is centered on the side axis . If the height of the element on the side axis is higher than its container , Then the overflow distance is the same in both directions
Reference documents :
align-items - CSS( Cascading style sheets ) | MDN
Here are two solutions :
1. Nested box
<style>
.container {
height: 100vh;
display: flex;
align-items: center;
overflow-y: auto;
}
.box {
height: 100%;
}
.content {
height: 600px;
}
</style>
<body>
<div class="container">
<div class="box">
<div class="content"></div>
</div>
</div>
</body>2. take display flex Change it to display grid
<style>
.box {
height: 100vh;
display: grid;
align-items: center;
overflow-y: auto;
}
.content {
height: 600px;
}
</style>
<body>
<div class="box">
<div class="content"></div>
</div>
</body>====================== Here's some bullshit , Don't look
because csdn Pretend you know the quality of the article
What you write less is poor quality , It won't push you up , It's funny
csdn New quality inspection function , Really? 6,“ yyds ”
I believe that this problem , My answer can solve 100% The problem of , You said my article was not good enough ?
Do you want me to write a lot of nonsense in the article ?
边栏推荐
猜你喜欢

MySQL advanced 2

Initial i/o and its basic operations

初始I/O及其基本操作

微信支付 APP端 第三弹 申请退款

Yunna | how to use the system to manage fixed assets? How to manage fixed assets?

云呐|固定资产信息系统管理,信息化固定资产管理
![[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network](/img/5d/9cff7bd25841c1ca6e5ab8e2994f51.png)
[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network

MySQL advanced 1

Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘

Quick pow: how to quickly find power
随机推荐
MySQL foundation 2
modbus-tcp-rtu协议图表
干外包3年,真废了...
网络方向哪个发展更好?数据通信工程师学习路线分享
Intermittent sampling and forwarding interference
HDCP Paring
Statistical query of SQL Server database
[MRCTF2020]Ezpop-1|php序列化
Byte, word, doubleword relationship
MySQL基础篇1
Lower expectations
Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
MySQL basics 1
Common interview questions for network workers: Telnet, TTL, router and switch
MySQL deadlock
C语言课设心得之“推箱子”课设作品开源分享
云呐|固定资产系统管理的优势,固定资产管理系统有何特点
Briefly: how are fragments communicated?
MySQL foundation 3
MySQL基礎2