当前位置:网站首页>绝对定位使盒子居中显示的三种方式
绝对定位使盒子居中显示的三种方式
2022-06-12 03:25:00 【stay calm~】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
body{
height: 8000px;
}
div{
width: 300px;
height: 200px;
background-color: aqua;
position: absolute;
/*四则运算 支持+ - 运算符符号前后写空格 */
top: calc(50% - 100px);
left: calc(50% - 150px);
}
.box{
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top:50%;
margin-top: -50px;
left:50%;
margin-left: -50px;
}
.box2{
width: 80px;
height: 80px;
background-color: blueviolet;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<div>方法一</div>
<div class="box">方法二</div>
<div class="box2">方法三</div>
</body>
</html>
边栏推荐
- How to prevent electrical fire in shopping malls?
- Paper recommendation: relicv2, can the new self supervised learning surpass supervised learning on RESNET?
- Three ways for ORALCE to process column to row conversion and finally generate table style data
- 【点云压缩】Variational Image Compression with A Scale Hyperprior
- [Business Research Report] 2021 global mobile game player white paper - download link attached
- 2020-12-06
- Demand and business model innovation - demand 9- prototype
- What is a request response pair called? [repeat] - what is a request response pair called? [duplicate]
- 大整数的加与乘;
- Leetcode 6[finding rules] Z-transform the leetcode path of heroding
猜你喜欢

微信小程序項目實例——體質計算器

Community Conference | the mosn community will release version 1.0 and promote the evolution of the next generation architecture

Redis gets the set of keys prefixed with XXX

2022 communication industry ultimate Exhibition Guide

2020-12-06

2020-12-07

Mosaïque d'images basée sur la matrice de transformation

Domestic mobile phones are snubbing low-end consumers, and Nokia provides them with high-quality products

The road of global evolution of vivo global mall -- multilingual solution

oralce 处理列转行的三种方式 最后生成表格样式数据
随机推荐
Sequence list and linked list ----- advanced
Final summary of addition, deletion, modification and query
【点云压缩】Sparse Tensor-based Point Cloud Attribute Compression
laravel 8 选用 jwt 进行接口验证
Go recursive infinite classification
Comparaison de la taille des fractions
Hudi of data Lake (14): basic concepts of Apache Hudi
微服务概念及介绍
2020-12-12
[Business Research Report] Research Report on super automation technology and application (2022) -- download link attached
如何修改mysql 查询出来的结果名称 结果1,结果2
The rise of another domestic mobile phone chip is close to the height reached by Huawei
errno: -4091, syscall: ‘listen‘, address: ‘::‘, port: 8000
Demand and business model innovation - demand 8- interview
Notes relatives à l'application du certificat de l'AC et de la paire de clés
【点云压缩】Variational Image Compression with A Scale Hyperprior
Exemple de projet d'applet Wechat - calculatrice de constitution
What is the core of Web3?
3769 moving stones (simulated)
Addition and multiplication of large integers;