当前位置:网站首页>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;
}
}
边栏推荐
- Angry bird design based on unity
- A method of using tree LSTM reinforcement learning for connection sequence selection
- node_exporter部署
- 从实时应用角度谈通信总线仲裁机制和网络流控
- SSL证书续费相关问题详解
- Download the first Tencent technology open day course essence!
- Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
- 2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
- 测试工程师如何“攻城”(下)
- IBM WebSphere MQ retrieving messages
猜你喜欢

Bi skills - permission axis

神经网络物联网应用技术就业前景【欢迎补充】

神经网络物联网是什么意思通俗的解释

Oracle with as ORA-00903: invalid table name 多表报错

A method of using tree LSTM reinforcement learning for connection sequence selection

千万不要只学 Oracle、MySQL!

Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project

读写关闭的channel是啥后果?

使用canal配合rocketmq监听mysql的binlog日志

基于lex和yacc的词法分析器+语法分析器
随机推荐
BI技巧丨权限轴
更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
Shell programming core technology "three"
Other InterSystems%net tools
Stream流
利用策略模式优化if代码【策略模式】
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
IBM WebSphere MQ检索邮件
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
发送和接收IBM WebSphere MQ消息
Basic tutorial of scala -- 16 -- generics
Leetcode ransom letter C # answer
6.26cf simulation race e: solution to the problem of price maximization
The kth largest element in the array
The 15th youth informatics competition in Shushan District in 2019
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
C language printing exercise
Rookie post station management system based on C language
Wireshark网络抓包
测试工程师如何“攻城”(下)