Created
June 6, 2021 11:03
-
-
Save isaacssemugenyi/f4fb9949b0c6f23fcd948e88bb13e32c to your computer and use it in GitHub Desktop.
Centering a circle or image in the middle of the div
This file contains hidden or 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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
html, | |
* { | |
height: 100vh; | |
box-sizing: border-box; | |
} | |
#container { | |
background-color: aliceblue; | |
display: flex; | |
justify-content: center; | |
} | |
#row { | |
width: 100%; | |
height: 50%; | |
display: flex; | |
flex-direction: row; | |
flex-wrap: wrap; | |
justify-content: space-between; | |
} | |
.col { | |
margin-top: 10px; | |
width: 300px; | |
height: 300px; | |
} | |
.inner { | |
height: 100px; | |
} | |
.col-1 { | |
background-color: blue; | |
} | |
.col-2 { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
background: linear-gradient(blue 50%, red 50%); | |
} | |
.col-3 { | |
background-color: red; | |
} | |
.img { | |
display: flex; | |
width: 80px; | |
height: 80px; | |
background-color: rgb(34, 194, 181); | |
border-radius: 50%; | |
border-width: 2px; | |
border-color: red; | |
justify-content: center; | |
align-items: center; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<div id="row"> | |
<div class="col"> | |
<div class="inner col-1"></div> | |
<div class="inner col-2"> | |
<div class="img">C</div> | |
</div> | |
<div class="inner col-3"></div> | |
</div> | |
<div class="col"> | |
<div class="inner col-1"></div> | |
<div class="inner col-2"> | |
<div class="img">C</div> | |
</div> | |
<div class="inner col-3"></div> | |
</div> | |
<div class="col"> | |
<div class="inner col-1"></div> | |
<div class="inner col-2"> | |
<div class="img">C</div> | |
</div> | |
<div class="inner col-3"></div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment