Rails:在我看来,这不起作用

时间:2015-08-08 14:31:55

标签: html ruby-on-rails twitter-bootstrap twitter-bootstrap-3 erb

我要向一个简单的问题道歉。

很难提取部分代码,因为我不知道哪里出错了。

这是我的arr http://pastie.org/10337500#71-79

问题是我想在两个index.html.erb之间添加一些空格。 然后,我在那里添加了很多div,但它似乎不起作用。

enter image description here

3 个答案:

答案 0 :(得分:0)

尝试</br>,如果这不起作用,可能是因为您的代码中某处有一些未关闭的标记。如果不这样做,那么只需在按钮上添加边距底部或在img容器中添加margin-top。

答案 1 :(得分:0)

添加<br> in the view layer. You'd better to use填充or页边距的加载不是一个好习惯。例如,尝试更改:

<div class="clearfix">

<div class="clearfix", style="margin-top: 50px">

答案 2 :(得分:0)

创建CSS间距小部件

有很多方法可以解决这个问题,但看起来你正在使用不同部分的页面进行应用,这需要使用自定义间距进行布局。

一种简单而灵活的方法是在CSS中创建图形分隔符。一个有一些想法的例子。

在您的assets / stylesheets / custom.css.scss

.gfx_mt_10 {
  margin-top:10px;
}

.gfx_margins_my_x_section {
  margin: 25px 25px 10px 10px ; /* Top Right Bottom Left */
}

在你的HTML中

<div class="gfx_mt_10">
  <p>Everything in here is the section with a margin of 10 pixels at the top.</p>      
</div>

<div class="gfx_my_x_section">
  <p>Everything in here is the section with a margin of 25 pixels at the top.</p>      
</div>

<div class="clearfix gfx_mt_10">
  <p>Everything in here is the section which combines clearfix attributes + a margin of 10 pixels at the top.</p>      
</div>

如果您像这些图形小部件一样创建CCS间隔符,则可以在任何类标记中使用它们。我不建议更改全局类似clearfix,这可能会在整个应用程序中产生意想不到的后果。

W3 CSS文档

如果您还没有,我强烈建议您阅读官方资源here中的CSS功能。

或使用Bootstrap网格系统

我应该补充一点,如果你使用Bootstrap,你的工作就完成了。有一个学习曲线,但它为你的UI创建了一个平台灵活的框架。