Inline-block elements and vertical-align reasoning

旧时模样 提交于 2019-12-02 11:06:46

UPDATE:

In your example just add:

.content_boxes{
    width: 400px;
    height: 200px;
    background: lightgreen;
    display: inline-block;
    vertical-align:top;
}

Fiddle:

http://jsfiddle.net/genwQ/1/

You have to set vertical-align:top; to each element is display:inline-block;. Careful not to confuse: it is the element, NOT the parent.

Example:

ul li {
    display:inline-block;
    vertical-align:top;
}

Demo:

http://jsfiddle.net/X3RLB/

Realize that an unwanted space appears between your inline-block elements. This space CANNOT be removed with the margin:0px; property. To remove them you must add a comment tag between inline-block the elements.

Example:

<div id="content_cnt">
    <div class="content_boxes"></div><!--
    --><div class="content_boxes">dsasda</div>
</div>

Fiddle:

http://jsfiddle.net/genwQ/2/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!