mercredi 6 juillet 2016

Circular divs with vertically aligned text and subtitles

I feel like this is really obvious but I couldn't seem to find any answers on here.

I'm trying to make 5 circular divs, inline, with a letter in the middle representing a grade. I then want the subject title below the grade (but still inside the circle).

Here is an example of what I'm trying to do.

Here's what I've written so far:

HTML:

<div class="subject">A</div>
<div class="subject">B</div>
<div class="subject">C</div>
<div class="subject">D</div>
<div class="subject">E</div>

CSS:

.subject {
    display: inline-block;
    background-color: gray;
    width: 200px;
    height: 200px;
    line-height: 200px;
    text-align: center;
    font-family: Arial;
    border-radius: 100%;
    color: white;
    font-size: 100px;

Also, I couldn't seem to horizontally center the circles using:

margin: 0 auto;

or

margin-left: auto;
margin-right: auto;

.subject {
  display: inline-block;
  background-color: gray;
  width: 200px;
  height: 200px;
  line-height: 200px;
  text-align: center;
  font-family: Arial;
  border-radius: 100%;
  color: white;
  font-size: 100px;
}
<div class="subject">A</div>
<div class="subject">B</div>
<div class="subject">C</div>
<div class="subject">D</div>
<div class="subject">E</div>

Any advice is appreciated, thanks!




Aucun commentaire:

Enregistrer un commentaire