当前位置:网站首页>页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
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;
}
}
边栏推荐
- Download the first Tencent technology open day course essence!
- ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
- 2022 ByteDance daily practice experience (Tiktok)
- Scala基础教程--15--递归
- Leetcode ransom letter C # answer
- Process of manually encrypt the mass-producing firmware and programming ESP devices
- Don't just learn Oracle and MySQL!
- 英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
- 更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
- 6.26cf simulation race e: solution to the problem of price maximization
猜你喜欢

Go microservice (II) - detailed introduction to protobuf

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

Go微服务(二)——Protobuf详细入门
Summary and sorting of 8 pits of redis distributed lock

2022CoCa: Contrastive Captioners are Image-Text Fountion Models

Scala基础教程--16--泛型

Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join

Nebula Importer 数据导入实践

与二值化阈值处理相关的OpenCV函数、方法汇总,便于对比和拿来使用

Scala基础教程--15--递归
随机推荐
自由小兵儿
Other InterSystems%net tools
Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
模板_大整数减法_无论大小关系
6.26CF模拟赛B:数组缩减题解
DeFi生态NFT流动性挖矿系统开发搭建
IBM WebSphere MQ检索邮件
基于lex和yacc的词法分析器+语法分析器
完善的js事件委托
1672. 最富有客户的资产总量
基于C语言的菜鸟驿站管理系统
OpenCV的二值化处理函数threshold()详解
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Scala basic tutorial -- 17 -- Collection
发送和接收IBM WebSphere MQ消息
BI技巧丨权限轴
Nebula importer data import practice
神经网络物联网应用技术就业前景【欢迎补充】
ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
Wireshark网络抓包