How do I leave the text at the center of the css3 ellipse?

Asked

Viewed 32 times

2

How to leave this text in the middle ?inserir a descrição da imagem aqui

css:

<style>
    .bg-maroon, .bg-aqua, .bg-yellow, .bg-red, .bg-teal, .bg-purple, .bg-orange, .bg-green {
        text-align: center;
        height: 70px;
        border-radius: 50px;

    }
    .row span {
        display: block;
        margin-left: auto;
        margin-right: auto;
        font-size: 18px;

    }
</style>
  • Have you tried with vertical-align or line-height?

1 answer

5


There are several ways to do, but in this case I think the ideal is to use a line-height with the same height value, as you can see in the example with your code

.bg-maroon,
.bg-aqua,
.bg-yellow,
.bg-red,
.bg-teal,
.bg-purple,
.bg-orange,
.bg-green {
  text-align: center;
  height: 70px; /* altura do btn */
  border-radius: 50px;
  line-height: 70px; /* mesmo valor da altura do btn para ajustar no centro vertical */
}

.bg-maroon {
  background-color: brown;
  color: #fff;
}

.row span {
  display: block;
  margin-left: auto;
  margin-right: auto;
  font-size: 18px;

}
<div class="row">
	<span class="bg-maroon">bg-maroon</span>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.