微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 垂直对齐范围内div

参见英文答案 > How to center an element horizontally and vertically?10个
http://jsfiddle.net/UmHNL/2/
<div class="container">

    <span>Some text,yay</span>

</div>

<div class="container">

    <span>Some text,yay. But shit time,there is alot of text,so we get a problem with breaking lines and the given height :( How can I align vertical Now?</span>

</div>
<style>
.container {
    width: 100%;
    height: 50px;
    line-height: 50px;
    border: 1px solid black;
}

.container span {
    padding-left: 30px;
}
</style>

这个解决方案的效果非常好,直到屏幕宽度太小 – 将我的文本打破了几行.

当我google这个问题,我发现这么多疯狂的过于复杂的解决方案与javascript和div推我的内容到位.任何人可以帮助我做这项工作,而不增加更多的标记

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。