|
@@ -0,0 +1,38 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <style>
|
|
|
+ .box{
|
|
|
+ width: 400px;
|
|
|
+ height: 400px;
|
|
|
+ border:1px dashed black;
|
|
|
+ margin:100px auto;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ .div1{
|
|
|
+ width: 200px;
|
|
|
+ height: 200px;
|
|
|
+ background-color: red;
|
|
|
+ /* transform: translateX(-100px) translateY(100px); */
|
|
|
+ /* transform: translate(100px,100px); */
|
|
|
+ /* 百分比相较于自己 */
|
|
|
+ /* transform: translate(50%,50%); */
|
|
|
+ position: absolute;
|
|
|
+ top:50%;
|
|
|
+ left: 50%;
|
|
|
+ /* margin-top: -100px;
|
|
|
+ margin-left: -100px; */
|
|
|
+ transform: translate(-50%,-50%);
|
|
|
+
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div class="box">
|
|
|
+ <div class="div1"></div>
|
|
|
+ </div>
|
|
|
+</body>
|
|
|
+</html>
|