Last active
July 12, 2021 20:51
-
-
Save callezenwaka/f64c19669b6e1b73ae2c4bf12905b952 to your computer and use it in GitHub Desktop.
How to center div with position absolute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.loader { | |
background-color: #000; | |
position: absolute; | |
height: 4rem; | |
width: 4rem; | |
left: 50%; | |
margin-left: -50px; | |
top: 50%; | |
margin-top: -50px; | |
z-index: 10000; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="loader"> | |
<div class="loader--wrapper"> | |
<span>😎</span> | |
</div> | |
</div> | |
<div>Source: <a href="https://thoughtbot.com/blog/positioning>thoughtbot</a></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment