当前位置:网站首页>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;
}
}
边栏推荐
- Principle and application of ThreadLocal
- 26. 删除有序数组中的重复项 C#解答
- 与二值化阈值处理相关的OpenCV函数、方法汇总,便于对比和拿来使用
- Pb extended DLL development (super chapter) (VII)
- 发送和接收IBM WebSphere MQ消息
- The 15th youth informatics competition in Shushan District in 2019
- Have you guys ever used CDC direct Mysql to Clickhouse
- 2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
- Stream流
- 国元期货是正规平台吗?在国元期货开户安全吗?
猜你喜欢
[release] a tool for testing WebService and database connection - dbtest v1.0
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
物联网应用技术的就业前景和现状
Summary and sorting of 8 pits of redis distributed lock
Torchdrug tutorial
每日一题(2022-07-02)——最低加油次数
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
神经网络物联网应用技术就业前景【欢迎补充】
One question per day (2022-07-02) - Minimum refueling times
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
随机推荐
IBM WebSphere MQ retrieving messages
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
Oracle with as ORA-00903: invalid table name 多表报错
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import 'fmt' func
Scala basic tutorial -- 19 -- actor
更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
Wireshark网络抓包
技术分享 | 接口测试价值与体系
《看完就懂系列》字符串截取方法substr() 、 slice() 和 substring()之间的区别和用法
The 300th weekly match of leetcode (20220703)
The 15th youth informatics competition in Shushan District in 2019
DeFi生态NFT流动性挖矿系统开发搭建
2022健康展,北京健博会,中国健康展,大健康展11月13日
2021 Hefei informatics competition primary school group
千万不要只学 Oracle、MySQL!
Send and receive IBM WebSphere MQ messages
Principle and application of ThreadLocal
Process of manually encrypt the mass-producing firmware and programming ESP devices
使用SSH
删除字符串中出现次数最少的字符【JS,Map排序,正则】