div 100px x 100px 内のテキストを垂直方向に揃えようとしています。問題は、フォントサイズを大きく設定すると、行の高さが考慮されないことです。
別のテストを行いますが、別の font-size(12px) で動作します。
どうすれば修正できますか?また、なぜこれが起こるのですか?
大きいフォント サイズ: http://jsfiddle.net/2sLNy/1/
小さなフォントサイズ: http://jsfiddle.net/2sLNy/2/
大きいフォント サイズのコード:
div{
position: relative;
width: 100px;
height: 100px;
background-color: #DDD;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
text-align: center;
line-height: 100px;
}
div:hover:before{
opacity: 1;
}
div:before{
opacity: 0;
position: absolute;
width: 100px;
height: 100px;
display: block;
text-align: center;
font-size: 12px;
color: #FFF;
content: " + ";
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
line-height: 100px;
}
ありがとう!