Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center a div in a circle

Tags:

html

css

I have a circle in which I can't center the div with text. I tried with flexbox but it doesn't seem to work or I did it wrong.

This is the code

.circle {
  border-radius: 50%;
  transition: all 2s;
  transition-delay: 0s;
  background-color: #14b1e7;
  width: 100%;
  padding-top: 100%;
  text-align: center;
}

.words {
  font-size: 40px;
  font-family: 'Montserrat', sans-serif;
  display: flex;
  animation-name: fade;
  animation-delay: 4s;
  animation-duration: 0.5s;
  animation-timing-function: ease-out;
  animation-iteration-count: forwards;
  animation-direction: absolute;
  font-weight: bold;
  justify-content: center;
  align-items: center;
}
<div class="circle">
  <div class="words"></div>
  <div class="words1"></div>
  <div class="words2"></div>
</div>
like image 722
Odenial Avatar asked Dec 06 '25 17:12

Odenial


1 Answers

You can use display:flex, align-items:center and justify-content:center

.circle{
  width: 100px;
  height: 100px;
  background-color: #14b1e7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
<div class="circle">
  <div>A</div>
  <div>B</div>
  <div>C</div>
</div>
like image 114
Cédric Avatar answered Dec 08 '25 07:12

Cédric



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!