html - Why does vertical-align not work in this case? -


i used align text inside divs css , vertical-align. i'm trying, can't work.

my task vertical-align: center; white text inside pink div. whatever do, text remains starting in upper left corner.

here html:

<div style="width:100%; text-align:center; background-color:#ff0000">   <div style="width: 587px; height: 180px; margin-left:auto; margin-right:auto; text-align:center; background-color:#00ff00">     <div style="height: 20px; width: 1px;"> </div>     <!--<br>-->     <div style="height: 30px; width: 530px; color: #ffffff; font-size: 16px; text-align: left; vertical-align: middle; margin-left:auto; margin-right:auto; background-color:#ff00ff">       <div style="display: table-cell; vertical-align: text-bottom;"> <b>center me vertically, please!</b> </div>     </div>   </div> </div> 

you can fiddle around it.

i tried different solutions found here on this site, can't them work. so why won't browser vertically align text in nice pink div?

i'm not sure if it's "proper" css way it, if set line-height of pink div same height (30px) center vertically:

<div style="width:100%; text-align:center; background-color:#ff0000"> <div style="width: 587px; height: 180px; margin-left:auto; margin-right:auto; text-align:center; background-color:#00ff00">     <div style="height: 20px; width: 1px;">     </div>     <!--<br>-->     <div style="height: 30px; line-height: 30px; width: 530px; color: #ffffff; font-size: 16px; text-align: left; vertical-align: middle; margin-left:auto; margin-right:auto; background-color:#ff00ff">         <div style="display: table-cell; vertical-align: text-bottom;">             <b>center me vertically, please!</b>         </div>     </div> </div> </div> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -