ruby-on-rails - CSS 使用 Rails 自动链接到 HTML
问题描述
我在 app/assets/stylesheets 中为我的 Ruby on Rails 项目创建了一个 style.css 文件。我添加了一些样式并启动了服务器。我没有在任何 html.erb 文件中放置任何<link href...>
或任何位置,但每个页面都有我在 style.css 中编写的 css 更改stylesheet_link_tag
此外,我现在必须在每次更改 CSS 时重新启动服务器才能在浏览器中看到这些更改。有没有人遇到过这个?顺便说一句,我正在使用动作电缆。我也没有 public/assets 文件夹。
应用程序.js
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("jquery")
$(document).on('turbolinks:load', function () {
alert("Hello!");
})
应用程序.css
/*
* 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, 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 other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
样式.css
table{
border-collapse: collapse;
}
table, th, td{
border: 1px solid black;
}
#left, #right {float:left}
#left {width: 30%;}
#right {width: 70%;}
解决方案
推荐阅读
- python - wb.DataReader 后的方括号
- mysql - MySQL在每组中选择第一个,第二个和最后一个值的最佳方法
- ssh - 如果我在运行程序时断开笔记本电脑与树莓派的连接会发生什么?
- azure - 多次读取 BrokeredMessage 正文
- c# - 如何使用 ComboBox SelectionChanged 事件更改 StackPanel 颜色?
- git - 无法使用 ansible 在本地进行 git clone
- ios - 如何在swift 4和xcode 9中的UITableViewCell中单击按钮更新UILabel?
- java - 创建新方法时如何初始化arrayList
- jquery - 返回Jtable的时间
- php - 在 PHP 中接收 geoJSON 多边形作为 POST 在 foreach 中不起作用