css - bootstrap-sass 2.3.2 与 Rails 4.0.0 : issue @extend . 控制组; &@extend.error;

标签 css ruby-on-rails twitter-bootstrap

我正在关注 http://www.railstutorial.org/book/_single-page 的 Rails 4.0.0 教程.

我检查了所有内容以匹配教程,但似乎无法找到问题。

我的 gem 文件:

gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'

所有 Bootstrap 似乎都有效,但错误的 @extend 似乎不起作用。我知道 bootstrap 2 和 3 之间存在差异。因此我严格按照这部分的教程进行操作:)

我的custom.css.scss

#error_explanation {
  color:#f00;
  ul {
    list-style: none;
    margin: 0 0 18px 0;
  }
}

.field_with_errors {
  @extend .control-group;
  @extend .error;
 }

生成的 HTML:

<...>
<div id="error_explanation">
    <div class="alert alert-error">
      The form contains 5 errors.
    </div>
    <ul>
      <li>* Name can&#39;t be blank</li>
      <li>* Email can&#39;t be blank</li>
      <li>* Email is invalid</li>
      <li>* Password can&#39;t be blank</li>
      <li>* Password is too short (minimum is 6 characters)</li>
    </ul>
</div>


      <div class="field_with_errors"><label for="user_name">Name</label></div>
      <div class="field_with_errors"><input id="user_name" name="user[name]" type="text" value="" /></div>

      <div class="field_with_errors"><label for="user_email">Email</label></div>
      <div class="field_with_errors"><input id="user_email" name="user[email]" type="text" value="" /></div>

      <div class="field_with_errors"><label for="user_password">Password</label></div>
      <div class="field_with_errors"><input id="user_password" name="user[password]" type="password" /></div>

<...>

enter image description here

enter image description here

最佳答案

我真是个傻子。当我开始这个元素时,我用脚手架生成了一些东西。完全忘记了。

如果您想摆脱脚手架,请按照说明操作:Getting rid of scaffold.css in rails

关于css - bootstrap-sass 2.3.2 与 Rails 4.0.0 : issue @extend . 控制组; &@extend.error;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23629360/

相关文章:

html - 是否可以在声明后设置元素的类别?

html - Angular ngFor : How to differentiate default value from others

ruby-on-rails - 子域名 Nginx 返回 403 禁止用于 unicorn/rails 设置

ruby-on-rails - 如何在 Facebook Canvas 上以不同方式显示我现有的 Rails 应用程序

html - Bootstrap 弹出窗口太窄

html - 将第二个导航栏放在第一个导航栏下方

html - 提交按钮周围带有渐变的奇怪边框。我该如何删除?

css - 正则表达式从图像中删除主机名

ruby-on-rails - Ruby on Rails - Autoprefixer 不支持 Node v4.9.1。更新它。怎么修?

html - 为什么我的导航栏链接是垂直显示的而不是水平显示的?