3

每当我将代码添加到我的 CSS 文件时,我都会在使用 Bootstrap 时收到此错误。

    Invalid CSS after "": expected selector or at-rule, was "<!DOCTYPE html>" (in /users/app_project/app/assests/stylesheets/custom.css.scss)

    Extracted source (around line #4):

    1: <!DOCTYPE html>
    2: <html>
    3:     <head>
    4:      <%= stylesheet_link_tag    "application", :media => "all" %>
    5:      <%= javascript_include_tag "application" %>
    6:      <%= csrf_meta_tags %>
    7:     </head>

我以前能够在没有任何错误的情况下向它添加代码,但在某些时候我必须在某个地方进行了更改,从而导致了这个问题。

这是我正在使用的原始 CSS,没有导致错误

     @import "bootstrap";

     /*universal*/

     html {
    overflow-y: scroll;
     }

    body {
    padding-top: 60px;
    }

    section {
    overflow: auto;
    }

    textarea {
    resize: vertical;
    }

    .center {
    text-align: center;
    }

    .center h1 {
    margin-bottom: 10px;
    }

    .container-fluid {
    background-color: #eee;
    }

    /* typography */

    h1, h2, h3, h4, h5, h6 {
    line-height: 1;
    }

    h1 {
    font-size: 3em;
    letter-spacing: -2px;
    margin-bottom: 30px;
    text-align: center;
    }

    h2 {
    font-size: 1.7em;
    letter-spacing: -1px;
    margin-bottom: 30px;
    text-align: left;
    font-weight: normal;
    color: black;
    }

    p {
    font-size: 1.1em;
    line-height: 1.7em;
    }

    #logo {
    float: left;
    margin-right: 10px;
    font-size: 1.7em;
    color: #d81010;
    text-transform: uppercase;
    letter-spacing: -1px;
    padding-top: 9px;
    font-weight: bold;
    line-height: 1;
    }

    #logo:hover {
    color: black;
    text-decoration: none;
    }

    li {
    text-align: left;
    }

    h1#class {
    color:#ff5a28;
    }

    .nav-center {
    color: blue;
    }

这是我尝试添加的一些导致错误的代码。

    * {
    margin: 0;
    }

    html, bodY {
    height: 100%;
    }

    .wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -4em;
    }

    .footer, .push {
    height: 4em;
    }

    footer {
    background-color: #70ff00;
    }

不仅仅是上面的代码会导致错误。任何额外的 CSS 都会导致我收到错误消息。

我究竟做错了什么?如果需要,我也可以发布我正在使用的 html 代码。

4

2 回答 2

1

我在使用 Middleman 时遇到了同样的问题。似乎构建过程试图将特定布局应用于源文件夹中的所有文件。稍微搜索一下,我就可以推断出该布局甚至被应用到了 bower 组件中存在的完整 HTML 测试文件。结果,测试文件中的标签嵌套在我的布局中的标签中。我通过在 config.rb 中指定布局仅应用于特定 HTML 文件的正则表达式解决了这个问题。

于 2013-12-15T10:29:57.190 回答
0

检查你的代码。你有

html, bodY {
height: 100%;
}

在 sass 文件中。将此代码转换为

html, body {
height: 100%;
}

你有错误的 CSS 正文标签。这导致错误。

于 2014-01-25T05:15:17.580 回答