当前位置:网站首页>绝对定位使盒子居中显示的三种方式
绝对定位使盒子居中显示的三种方式
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>
边栏推荐
- 3768 string pruning (double pointer)
- Mysql/oracle takes the unique time as the boundary, and the sum is less than or equal to this time, and greater than this time
- Batch automated e-mail: Vika Vige table x Tencent Qianfan scene connector has made new moves, and business communication and event marketing only need 3 steps
- In 2022, don't you know the difference between arrow function and ordinary function?
- 分布式计算的八大谬论
- Demand and business model innovation - demand 11 - overview of demand analysis
- An example of how to migrate the stock equipment of the Internet of things platform to the enterprise version with one click
- 2020-12-12
- The idea of setting the flash memory management and resource size, and the quantitative relationship among parallelism, slot, and taskmanager quantity
- Computer common sense
猜你喜欢

errno: -4091, syscall: ‘listen‘, address: ‘::‘, port: 8000

Sparse tensor based point cloud attribute compression

Redis gets the set of keys prefixed with XXX

如何防止商场电气火灾的发生?

Requirements and business model innovation - Requirements 12 - process oriented modeling

In 2022, don't you know the difference between arrow function and ordinary function?

Unity3d ugui translucent or linear gradient pictures display abnormally (blurred) problem solving (color space mismatch)

What is the core of Web3?

2020-12-07

Comparaison de la taille des fractions
随机推荐
Hudi of data Lake (14): basic concepts of Apache Hudi
Leetcode 6[finding rules] Z-transform the leetcode path of heroding
推荐6款办公软件,好用还免费,效率翻倍
Three ways for ORALCE to process column to row conversion and finally generate table style data
xml
Demand and business model innovation - demand 8- interview
安科瑞抗晃电产品在河北某化工项目的应用
2020-12-06
errno: -4091, syscall: ‘listen‘, address: ‘::‘, port: 8000
字符串处理:
Steamvr--- grab objects
Addition and multiplication of large integers;
2020-12-06
[Bank Research Report] technology enabled retail finance carbon neutral development report (2022) - download link attached
MySQL创建用户并授权
Oracle users and tablespaces
Application of ankery anti shake electric products in a chemical project in Hebei
【点云压缩】Variational Image Compression with A Scale Hyperprior
2020-12-17
2020-12-07