html – 垂直对齐范围内div

前端之家收集整理的这篇文章主要介绍了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推我的内容到位.任何人可以帮助我做这项工作,而不增加更多的标记 原文链接:https://www.f2er.com/html/231432.html

猜你在找的HTML相关文章