html - How to vertically align the text into a coloured div using CSS? -
i need vertically align text div have height.
if go here can see problem: http://onofri.org/example/example3/
as can see have #titlebox div contain text: promoting investment in agriculture
the #titlebox have specific height 40px. want vertically align text in green div in such way @ center.
this html , css code don't work well:
<div id="container"> <div id="titlebox"> <p id="mytitle">promoting investment in agriculture</p> </div> </div> #titlebox{ margin: 0 auto; width: 350px; background-color: #6da662; height: 40px; vertical-align: middle; } #mytitle{ /* consente di posizionare un elemento al centro del suo contenitore */ margin: 0 auto; overflow: hidden; color: #fff; font-size: 16.5px; font-weight: bold; text-align: center; }
what have solve?
tnx
andrea
try add these styles #mytitle
:
vertical-align: middle; line-height: 40px;
Comments
Post a Comment