- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>Centering with transform: translate</title>
<meta charset="utf-8">
<link rel="stylesheet" href="world.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="world homeworld">
<div class="picture-frame large active">
<div class="picture"></div>
</div>
</div>
</body>
</html>
CSS
.picture {
position: relative;
width: 50%;
height: 50%;
}
You’ve gone to a different page
Goalscompleted
0
- Assign the
left: 50%
property to the.picture
block. - And also assign the property
top: 50%
. - Then move it by setting
translateX
to-50%
. - And shift it by
-50%
usingtranslateY
.
Comments