xxxxxxxxxx
<!DOCTYPE html>
<html lang="en">
<head>
<title>
How to center a position:fixed element ?
</title>
<style>
body {
font-family: sans-serif;
padding: 0;
margin: 0;
background-color: black;
color: white;
}
.container {
border: 2px solid white;
width: 50%;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
h1 {
color: springgreen;
}
</style>
</head>
<body>
<div class="container">
<h1>GeeksforGeeks</h1>
<h3>How to center a position:fixed element?</h3>
</div>
</body>
</html>