<!DOCTYPE html>
<html lang=zh-cn>
<head>
<meta charset=utf-8>
<title>CSS实现块级元素水平垂直居中</title>
<meta name=description content=CSS实现块级元素水平垂直居中>
<meta name=author content=Roc>
<meta name=copyright content=Roc>
<link rel=shortcut icon href=favicon.ico>
<link rel=apple-touch-icon href=custom_icon.png>
<meta name=viewport content=width=device-width, user-scalable=no >
<link rel=stylesheet href=main.css>
<style>
body{
background:#aabbcc;
}
.loginDiv{
width:600px;
border:1px dashed gray;
border-radius:15px;
padding:20px;
position: absolute;
top: 50%;
left:50%;
transform:translateX(-50%) translateY(-50%);
}
</style>
<script src=script.js></script>
</head>
<body>
<div class="loginDiv">
这里是正文部分
</div>
</body>
</HTML>
css实现块级元素水平和垂直居中
最新推荐文章于 2022-12-22 11:41:55 发布