当前位置:网站首页>页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
2022-07-04 17:47:00 【回忆哆啦没有A梦】
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中
// 1
.wrapper {
position: relative;
.box {
position: absolute;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
margin: -50px 0 0 -50px;
}
}
// 2 我最常用的
.wrapper {
position: relative;
.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
// 伪类+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;
}
}
边栏推荐
- 模板_判断素数_开方 / 六素数法
- 神经网络物联网应用技术就业前景【欢迎补充】
- 1672. Total assets of the richest customers
- 物联网应用技术的就业前景和现状
- 从实时应用角度谈通信总线仲裁机制和网络流控
- 其他InterSystems %Net工具
- Go microservice (II) - detailed introduction to protobuf
- 性能优化之关键渲染路径
- Leetcode ransom letter C # answer
- What if the self incrementing ID of online MySQL is exhausted?
猜你喜欢

性能优化之关键渲染路径

学习路之PHP--phpstudy创建项目时“hosts文件不存在或被阻止打开”
![[go ~ 0 to 1] read, write and create files on the sixth day](/img/cb/b6785ad7d7c7df786f718892a0c058.png)
[go ~ 0 to 1] read, write and create files on the sixth day

奥迪AUDI EDI INVOIC发票报文详解

Scala basic tutorial -- 13 -- advanced function

Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?

TorchDrug教程

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

基于lex和yacc的词法分析器+语法分析器

LeetCode第300场周赛(20220703)
随机推荐
国元期货是正规平台吗?在国元期货开户安全吗?
2022 ByteDance daily practice experience (Tiktok)
Li Chi's work and life summary in June 2022
【uniapp】uniapp开发app在线预览pdf文件
Deleting nodes in binary search tree
The CDC of sqlserver can read the data for the first time, but it can't read the data after adding, deleting and modifying. What's the reason
Scala basic tutorial -- 18 -- set (2)
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
Summary and sorting of 8 pits of redis distributed lock
自由小兵儿
Li Kou brush question diary /day2/2022.6.24
Wireshark网络抓包
How is the entered query SQL statement executed?
Go微服务(二)——Protobuf详细入门
LeetCode第300场周赛(20220703)
Nebula importer data import practice
Caché JSON 使用JSON适配器
使用canal配合rocketmq监听mysql的binlog日志
6.26cf simulation match B: solution to array reduction problem
2022CoCa: Contrastive Captioners are Image-Text Fountion Models