简体   繁体   English

使用具有内联块间隔间隙的Haml

[英]Using Haml with the inline-block spacing gaps

So I read the solutions regarding making the spacing go away when using inline-block as opposed to floats: display: inline-block extra margin and http://css-tricks.com/fighting-the-space-between-inline-block-elements/ . 因此,当使用内联块而不是浮动时,我阅读了关于使间距消失的解决方案: 显示:内联块额外边距http://css-tricks.com/fighting-the-space-between-inline-block - 元素/

So if you're using haml and want to put the closing tag on the same line as the next opening tag, is there is a solution besides switching to ERB? 因此,如果您正在使用haml并希望将结束标记放在与下一个开始标记相同的行上,那么除了切换到ERB之外还有解决方案吗?

(and no, I don't want to mess with a css property of the parent container and have to override that in all the child elements). (不,我不想弄乱父容器的css属性,并且必须在所有子元素中覆盖它)。

This breaks (has spacing between the anchors). 这打破了(锚之间有间距)。

So is it true that in spite of the recommendations to do such layouts using inline-block as opposed to floats, it seems that floats are still the way to go, especially when using haml? 因此,尽管建议使用内联块而不是浮点数来进行此类布局,但似乎浮动仍然是要走的路,特别是在使用haml时?

CSS CSS

nav a {
  display: inline-block;
  padding: 5px;
  background: red;
}

HTML HTML

<nav>
  <a href="#">One</a>
  <a href="#">Two</a>
  <a href="#">Three</a>
</nav>

Workaround (css-tricks one): 解决方法(css-tricks one):

<ul>
  <li>
   one</li><li>
   two</li><li>
   three</li>
</ul>

or 要么

<ul>
  <li>one</li
  ><li>two</li
  ><li>three</li>
</ul>

another one: 另一个:

<ul>
  <li>one</li><!--
  --><li>two</li><!--
  --><li>three</li>
</ul>

I found the answer: http://haml.info/docs/yardoc/file.REFERENCE.html#whitespace_removal__and_ 我找到了答案: http//haml.info/docs/yardoc/file.REFERENCE.html#whitespace_removal__and_

(this is a super useful article on the topic: http://designshack.net/articles/css/whats-the-deal-with-display-inline-block/ ) (这是关于该主题的超级有用的文章: http//designshack.net/articles/css/whats-the-deal-with-display-inline-block/

Here's a codepen to experiment: http://cdpn.io/Bjblr 这是一个实验的代码: http ://cdpn.io/Bjblr

在此输入图像描述

在此输入图像描述

在此输入图像描述

And this worked: 这有效: 在此输入图像描述

在此输入图像描述

Here's the html if the anchor text is on the same line (same result, but harder to read source html: 这是html如果锚文本在同一行(相同的结果,但更难阅读源html:

在此输入图像描述

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM