Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Oval buttons with border-radius 50%

i’m trying to achieve a round button style, but because of the content within the button i keep getting an oval shape, like inside the picture:

this

Maybe i got the wrong idea and the content is not the problem, I’m looking for ideas 🙂

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.ratingButton {
  position: relative;
  border: none;
  font-size: 18px;
  color: hsl(217, 12%, 63%);
  margin: 0 18px;
  background-color: hsla(216, 12%, 54%, 0.2);
  padding: 1em;
  border-radius: 50%; //tried w/ 50%, 100%, 100vh/vw, nothing seem to work.
}
<button class="ratingButton" id="fifth">5</button>

>Solution :

You can set a height and width, and modify padding accordingly.

Setting them as children of a flexbox is still possible with a desired layout:

.parent {
  width: 500px;
  outline: 1px solid salmon;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ratingButton {
  position: relative;
  border: none;
  font-size: 18px;
  color: hsl(217, 12%, 63%);
  background-color: hsla(216, 12%, 54%, 0.2);
  padding: .75em;
  border-radius: 50%;
  height: 50px;
  width: 50px;
}
<div class="parent">
  <button class="ratingButton" id="1">1</button>
  <button class="ratingButton" id="2">2</button>
  <button class="ratingButton" id="3">3</button>
  <button class="ratingButton" id="4">4</button>
  <button class="ratingButton" id="5">5</button>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading