Issue
How do I vertically align text that is inside of the cboxTitle-div (e.g. close-Box(text))? I use colorbox for making modal popups.
The div-structure is this:
<div id="cBoxContent">
<div id="cBoxTitle"></div>
</div>
CSS code:
#cboxContent{overflow:hidden; background: #121219;
}
#cboxTitle{position:absolute; top:0; left:0; text-align:left; width:100%; color:#999; height: 38px;}
Solution
You can vertically center text by setting its line-height
property to the height of the element it's sitting in.
#cboxTitle{
position:absolute;
top:0;
left:0;
text-align:left; width:100%;
color:#999;
height: 38px;
line-height: 38px;
}
This trick will only work if you know the height of your div
, of course. There are other methods, but they're more complex.
Another method that isn't linked is to set the div
containing your text to position: relative;
, then setting top
to 50% minus the one half the height of the element. This is best done in Javascript.
Answered By - Elliot Bonneville Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.