Whitespace causing divs to stack in Pure CSS [duplicate]

帅比萌擦擦* 提交于 2019-12-04 10:12:35

This is true for inline-block elements. Comment them out:

<div class="pure-u-1-2"><!--
    --><div class="pure-u-1-3"><p>Hello world</p></div><!--
    --><div class="pure-u-1-3"><p>Hello</p></div><!--
    --><div class="pure-u-1-3"><p>Hey there</p></div>
</div>
Len Paulsen

This previous thread on the subject should be of interest to you. Please follow this link, as this has been extensively tested and discussed HERE.

Whitespace makes a difference in the rendering of inline elements, but everything beyond a single one is always reduced to one whitespace.

sine css is dividing the with pure-u-1-3- 33.333% for one item and if we put three in a box( pure-u-1-2) its full , so no space for whitespace..

So if you put white space the last div goes down because of lack of space.

display: inline-block will always keep the whitespace between your elements if there is any. There are several hacks to get rid of the whitespace between the elements. You can find some good ones here. I personally think the font-size: 0pxhack works best, though it can be a hassle if you're working with EM's

What I really would suggest though would be to use float:left instead of display: inline-block. This way you can avoid having to use any dirty hacks to make it work.

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