I have a number of ovals I need to put into a WordPress page so it looks like;
oval - paragraph
paragraph - oval
oval - paragraph
paragraph - oval
oval - paragraph
I have no problems creating the oval, however I need to style it so no matter what heading text I put into each oval – it stays uniform.
I have put hard values in using padding-top however for 1 line headers this is no longer going to be centered.
How can I approach this better?
div {
background-color: #1468a8;
width: 300px;
height: 150px;
margin: 100px auto 0px;
border-radius: 50%;
color: white;
font-size: 1.6em;
}
p {
text-align: center;
padding-top: 14%;
}
<div>
<p>Accepting Divergence;
<br/>Affirming Values
</p>
</div>
You can remove the height of the
div
and use top/bottom padding to center the text verticaly :demo
NOTE: you also forgot the closing tag for the
<p>
elementYou can use following css to make div and text center. Use
display: table;
andtable-cell
will solved your issue.Check Fiddle.
See the fiddle, I have added two more oval in HTML, which contains different content, all three inherits same class still vertical and middle alignment is perfect for all three. here is fiddle for the same
https://jsfiddle.net/nileshmahaja/rv7mnw7s/
Below is my code
The HTML
The CSS