【问题标题】:Simple Form Not Showing Properly简单表格未正确显示
【发布时间】:2016-05-29 23:07:40
【问题描述】:

我目前正在学习来自 Rails Tutorial Instagram 的教程,但我似乎无法正确设置简单表单/Boostrap 样式。

(相关部分的CTRL+F:我仍然对这个表单的外观不太满意)

顶部来自教程,底部是我的:

以下是相关文件:

我的 CSS:

body {
  background-color: #fafafa;
  font-family: proxima-nova, 'Helvetica Neue', Arial, Helvetica,
  sans-serif;
}

.navbar-brand {
  a {
    color: #125688;
  }
}

.navbar-default {
  background-color: #fff;
  height: 54px;
  .navbar-nav li a {
    color: #125688;
  }
}

.navbar-container {
  width: 640px;
  margin: 0 auto;
}
.posts-wrapper {
  padding-top: 40px;
  margin: 0 auto;
  max-width: 642px;
  width: 100%;
}
.post {
  background-color: #fff;
  border-color: #edeeee;
  border-style: solid;
  border-radius: 3px;
  border-width: 1px;
  margin-bottom: 60px;
}
.post-head {
  height: 64px;
  padding: 14px 20px;
  color: #125688;
  font-size: 15px;
  line-height: 18px;
  .thumbnail {}
  .name {
    display: block;
  }
}
.image {
  border-bottom: 1px solid #eeefef;
  border-top: 1px solid #eeefef;
}
.caption {
  padding: 24px 24px;
  font-size: 15px;
  line-height: 18px;
}
.form-wrapper {
  width: 60%;
  margin: 20px auto;
  background-color: #fff;
  padding: 40px;
  border: 1px solid #eeefef;
  border-radius: 3px;
}
.edit-links {
  margin-top: 20px;
  margin-bottom: 40px;
}

我的 HTML 文件:

<div class="form-wrapper">
    <%= simple_form_for @post, html: { class: 'form-horizontal', multipart: true } do |f| %>
    <div class="form-group">
        <%= f.input :image %>
    </div>
    <div class="text-center">
        <%= f.input :caption, placeholder: 'Enter caption here' %>
    </div>
    <div class="text-center">
        <%= f.button :submit, class: 'btn-success' %>
        <% end %>
    </div>
</div>

【问题讨论】:

    标签: css ruby-on-rails ruby twitter-bootstrap simple-form


    【解决方案1】:

    添加 .form-group 以形成输入以更改您的 html,如下所示:

    <div class="form-wrapper">
        <%= simple_form_for @post, html: { class: 'form-horizontal', multipart: true } do |f| %>
        <div class="form-group">
            <%= f.input :image %>
        </div>
        <div class="form-group text-center">
            <%= f.input :caption, placeholder: 'Enter caption here' %>
        </div>
        <div class="form-group text-center">
            <%= f.button :submit, class: 'btn-success' %>
            <% end %>
        </div>
    </div>
    

    【讨论】:

    • 我做了,它什么也没做。 :(
    猜你喜欢
    • 2014-02-27
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 2013-03-21
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多