当前位置:网站首页>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;
}
}
边栏推荐
- 千万不要只学 Oracle、MySQL!
- 26. Delete the duplicate item C solution in the ordered array
- 测试工程师如何“攻城”(下)
- 使用SSH
- php伪原创api对接方法
- Shell 编程核心技术《三》
- Wechat reading notes of "work, consumerism and the new poor"
- The 15th youth informatics competition in Shushan District in 2019
- Scala basic tutorial -- 14 -- implicit conversion
- prometheus安装
猜你喜欢

Torchdrug tutorial

英特尔集成光电研究最新进展推动共封装光学和光互连技术进步

小发猫物联网平台搭建与应用模型

To sort out messy header files, I use include what you use

升级智能开关,“零火版”、“单火”接线方式差异有多大?

Principle and application of ThreadLocal

更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?

Basic tutorial of scala -- 16 -- generics

Scala basic tutorial -- 20 -- akka

从实时应用角度谈通信总线仲裁机制和网络流控
随机推荐
《看完就懂系列》字符串截取方法substr() 、 slice() 和 substring()之间的区别和用法
Unity editor extends C to traverse all pictures in folders and subdirectories
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
读写关闭的channel是啥后果?
LM10丨余弦波动顺势网格策略
php伪原创api对接方法
使用SSH
Perfect JS event delegation
Li Chi's work and life summary in June 2022
MySQL数据库基本操作-DDL | 黑马程序员
生成XML元素
删除字符串中出现次数最少的字符【JS,Map排序,正则】
Wireshark网络抓包
Shell programming core technology II
Using SSH
建立自己的网站(15)
LeetCode第300场周赛(20220703)
BI技巧丨权限轴
Shell programming core technology "four"