当前位置:网站首页>页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
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;
}
}
边栏推荐
- 2022CoCa: Contrastive Captioners are Image-Text Fountion Models
- 2022CoCa: Contrastive Captioners are Image-Text Fountion Models
- 爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
- Caché JSON 使用JSON适配器
- .NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
- How to modify icons in VBS or VBE
- 26. 删除有序数组中的重复项 C#解答
- 神经网络物联网是什么意思通俗的解释
- 建立自己的网站(15)
- 模板_大整数减法_无论大小关系
猜你喜欢

奥迪AUDI EDI INVOIC发票报文详解

How is the entered query SQL statement executed?

The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology

2022年字节跳动日常实习面经(抖音)

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

自由小兵儿
redis分布式锁的8大坑总结梳理

神经网络物联网平台搭建(物联网平台搭建实战教程)
Summary and sorting of 8 pits of redis distributed lock

Scala基础教程--20--Akka
随机推荐
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
Scala基础教程--12--读写数据
Rookie post station management system based on C language
问下各位大佬有用过cdc直接mysql to clickhouse的么
信息学奥赛一本通 1336:【例3-1】找树根和孩子
Mxnet implementation of googlenet (parallel connection network)
Scala basic tutorial -- 12 -- Reading and writing data
6.26cf simulation match B: solution to array reduction problem
2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
Unity editor extends C to traverse all pictures in folders and subdirectories
Caché WebSocket
Other InterSystems%net tools
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
Li Kou brush question diary /day1/2022.6.23
Technology sharing | interface testing value and system
性能优化之关键渲染路径
建立自己的网站(15)
Scala basic tutorial -- 17 -- Collection
Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
Nebula Importer 数据导入实践