-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcenterDIV3ways.html
More file actions
44 lines (42 loc) · 1.08 KB
/
centerDIV3ways.html
File metadata and controls
44 lines (42 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<title>3 Ways To Center a div in another div</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.parent_div{
background: aqua;
width: 100vw;
height: 100vh;
/* 1st METHOD */
/* position: relative; */
/* 2nd METHOD */
/* display: flex;
align-items: center;
justify-content: center; */
/* 3rd METHOD */
display: grid;
place-items: center;
}
.child_div{
width: 60vw;
height: 60vh;
background-color:green ;
/* position: absolute;
left: 50%;
top: 50%;
transform:translate(-50%,-50%) ; */
}
</style>
</head>
<body>
<div class="parent_div">
<div class="child_div">
</div>
</div>
</body>
</html>