我在主页上有一个较大的徽标,该徽标应居中对齐。我设法将其水平居中,而不是垂直居中。我唯一想到的解决方案是将最高利润设置为20%,但这似乎对于响应式设计不是一个好的解决方案。有什么合适的解决方案?
这是HTML:
<section id="home">
<div class="container">
<img id="logo2" class="img-responsive" src="img/logo2.png" >
</div> <!--end container-->
</section> <!--end home-->
这是CSS:
#logo2 {
margin: 0 auto;
margin-top: 20%;
}
这是主页本身的链接:http : //skiest.ragne.me/。
谢谢您的帮助。
如果元素具有声明的高度,则可以通过将其包装在父容器中来对其进行绝对定位:
.parent {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
text-align: center;
height: 100px; /* Or whatever height it is */
}
.child {
display: inline-block;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句