我有这样的代码设置:http : //jsfiddle.net/LtzhN/
我想垂直对齐容器中间的蓝色按钮,但是容器没有固定的高度。
如何做到这一点,最好只是在CSS中?
我知道我可以在jquery中执行以下操作:
var halfOuterHeight = $('.jbe-result').height()/2,
halfButtonHeight = $('.jbe-run').height()/2;
$('.jbe-run').css('margin-top', halfOuterHeight - halfButtonHeight)
但身份证而不是!
您不需要按钮的特殊容器,只需要CSS(顶部边距是按钮height
+vertical padding
的一半)。
.jbe-run {
margin-top: -11px;
padding:4px 10px;
width:70px;
color:#ffffff;
font-size:12px;
border-radius:4px;
-webkit-border-radius:4px;
text-align: center;
position: absolute;
top: 50%;
right: 10px;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句