当前位置:网站首页>The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
2022-07-04 19:25:00 【Memories do not have a dream】
Page elements centered vertically and horizontally 、 Vertical horizontal centering of known or unknown width
// 1
.wrapper {
position: relative;
.box {
position: absolute;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
margin: -50px 0 0 -50px;
}
}
// 2 What I use most
.wrapper {
position: relative;
.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
// pseudo-classes +vertical-align: middle;
.box{
vertical-align: middle;
display: inline-block;
}
.wrapper::after{
content: '';
height: 100%;
width: 0;
vertical-align: middle;
display: inline-block;
}
// 3
.wrapper {
.box {
display: flex;
justify-content:center;
align-items: center;
height: 100px;
}
// 4
.wrapper {
display: table;
.box {
display: table-cell;
vertical-align: middle;
}
}
边栏推荐
- 2022 ByteDance daily practice experience (Tiktok)
- In flinksql, in addition to data statistics, is the saved data itself a state
- From automation to digital twins, what can Tupo do?
- Have you guys ever used CDC direct Mysql to Clickhouse
- Leetcode fizzbuzz C # answer
- 建立自己的网站(15)
- To sort out messy header files, I use include what you use
- [go ~ 0 to 1] read, write and create files on the sixth day
- 2021 Hefei informatics competition primary school group
- Technologie de base de la programmation Shell IV
猜你喜欢
随机推荐
Angry bird design based on unity
[go ~ 0 to 1] read, write and create files on the sixth day
2019年蜀山区第十五届青少年信息学竞赛
[release] a tool for testing WebService and database connection - dbtest v1.0
Li Chi's work and life summary in June 2022
自由小兵儿
prometheus安装
Don't just learn Oracle and MySQL!
数组中的第K个最大元素
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
The kth largest element in the array
Scala basic tutorial -- 19 -- actor
IBM WebSphere MQ检索邮件
Scala basic tutorial -- 12 -- Reading and writing data
SSL证书续费相关问题详解
正则替换【JS,正则表达式】
C#实现定义一套中间SQL可以跨库执行的SQL语句(案例详解)
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
读写关闭的channel是啥后果?
Nebula Importer 数据导入实践