Currently, I am experimenting with creating an Img hover for entertainment purposes. However, I have added some text to my div. In order to center the text beautifully within my div, I utilized the following CSS code:
display: table-cell;
vertical-align: middle;
In addition, I have implemented the following CSS code as well:
.vertical-smallborder{
position: relative;
width: 217px;
height: 350px;
border: 5px solid white;
outline: 1px solid #c8c8c8;
float:left;
display: table;
-webkit-transition: all .3s;
-moz-transition: all .3s;
-ms-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
overflow: hidden;
}
I specifically included the display: table
in this section to facilitate text alignment. Removing it would disrupt the centered positioning of the text.
However, I encountered a complication with the use of overflow: hidden
. This property no longer functions properly in FireFox and IE when combined with display: table
.
On the contrary, both Google Chrome and Safari enable seamless compatibility between display: table
and overflow: hidden
.
Please note that I prefer a pure CSS solution and cannot incorporate any JavaScript for this task.
Thank you!