I am currently working on a periodic table, and although I got the mass and the number to be placed where I want them to, the element symbol just won't budge. I tried everything: converting it from <p>
to <span>
to <div>
, using display: block
and setting margin: 0 auto
, using text-align: center
, but it still won't budge.
Here's the HTML:
<div id = "a1" class="element alkalimetal">
<p>
<span id = "anumber">118</span>
<span id = "amass">9.008</span>
</p>
<br>
<div id = "symbol">H</div>
</div>
<div id = "a2" class = "element noblegas">
</div>
Here's the CSS:
#anumber{
font-family:Arvo;
top: 0.1em;
position:relative;
vertical-align:super;
font-size:1.5em;
float:left;
padding-left:0.2em;
}
#symbol{
width: 5em;
font-family: AvenirCondensed;
font-size: 5em;
text-align:center;
margin: 0 auto;
}
#amass{
font-family:AvenirNext;
top: 0.1em;
position:relative;
vertical-align:super;
font-size:1.5em;
float:right;
padding-right:0.2em
}
.element{
border: 1px solid black;
border-radius: 3px;
height: 8em;
width: 8em;
float: left;
}
P.S.: This table is designed for mobile so I want to avoid using position:absolute
or fixed margin widths.