margin:auto不垂直工作? [英] margin : auto not working vertically?

查看:130
本文介绍了margin:auto不垂直工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在外部div中垂直居中一个div,但它不工作。我试图在网上查找,但找不到我的具体问题的解释...
当尝试水平对齐时它的工作=>margin:0 auto;

I try to vertically center a div in an outer div but it doesn't work. I tried to look around on the web but couldn't find an explanation for my specific problem... When trying to align horizontally it's working => "margin:0 auto;"

任何人?

<div style="height:240px;width:100%;">

 <div style="width:33%;height:100px;margin:auto 0;">
   <span class="" style="font-size:26px">Hello </span>
   <br/><br/>
   <img style="width:150px" src="example.jpeg"
/>
 </div>

</div>


推荐答案

你总是可以看看这个链接。它有很多方法来做到只使用CSS。其中一个可能符合您的需要。 http://css-tricks.com/centering-in-the-unknown/

You could always take a look at this link. It has a number of ways to do it with just CSS. One of them may fit your needs. http://css-tricks.com/centering-in-the-unknown/

这篇关于margin:auto不垂直工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆