gpt4 book ai didi

ruby-on-rails - "...trap-sprockets"之后无效的 CSS“: expected selector or at-rule, 是 "@import "bootst...”

转载 作者:行者123 更新时间:2023-12-04 05:45:16 24 4
gpt4 key购买 nike

我是 Rails 的新手,正在尝试自学编程。我用 Bootstrap 制作了一个简单的 Rails 应用程序。我面临的问题是我添加了带有固定顶部的引导导航栏,然后我添加了

body {
padding-top: 60px;

但我陷入了一个错误:

Sass::SyntaxError in Pages#dashboard

Showing C:/Sites/tapo/app/views/layouts/application.html.erb where line #5 raised:

Invalid CSS after "...trap-sprockets"": expected selector or at-rule, was "@import "bootst..."

Rails.root: C:/Sites/tapo
Application Trace | Framework Trace | Full Trace

app/assets/stylesheets/application.css.scss:20
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___552321104_73620060'

我的 application.html.erb

    <!DOCTYPE html>
<html>
<head>
<title>Tapo</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<div class="container">
<%= yield %>
</div>
</body>
</html>

我的 application.css.scss

    /*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*= require font-awesome
*/

@import "bootstrap-sprockets"
@import "bootstrap"

body {
padding-top: 60px;
}

最佳答案

尝试关闭你的 @import 行,像这样:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*= require font-awesome
*/

@import "bootstrap-sprockets";
@import "bootstrap";

body {
padding-top: 60px;
}

关于ruby-on-rails - "...trap-sprockets"之后无效的 CSS“: expected selector or at-rule, 是 "@import "bootst...”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35741974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com