I have listed my codes below:
HTML code:
<div id="click">Click Here</div>
<div id="display" style="display:none">Message</div>
CSS code:
#click, #display{
width: 500px;
height: 50px;
background-color: #e5eecc;
border: solid 1px #c3c3c3;
text-align: center;
vertical-align: middle;
display: table-cell;
position: relative;
}
#display{
height: 100px;
position: absolute;
text-align: center;
vertical-align: middle;
display: table-cell;
}
jquery code:
$(document).ready(function(){
$('#click').click(function(){
$('#display').slideToggle();
});
});
The 1st div was perfectly aligned in the "center" & the "toggle slide" for 2nd div also worked well but the text "Message" didn't appear in the "vertical center" of the box. Instead, It appeared just on the "top center" of the box.
Please, suggest some alternatives to correct the problem. Thank you!