zoukankan      html  css  js  c++  java
  • rails使用bootstrap

    在Gemfile文件中添加'bootstrap-sass',再运行bundle install

    gem 'bootstrap-sass'

    在config/application.rb添加一行代码,让bootstrap-sass和asset pipeline兼容

      class Application < Rails::Application
        # Settings in config/environments/* take precedence over those specified here.
        # Application configuration should go into files in config/initializers
        # -- all .rb files in that directory are automatically loaded.
    
        # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
        # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
        # config.time_zone = 'Central Time (US & Canada)'
    
        # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
        # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
        # config.i18n.default_locale = :de
    
        # Do not swallow errors in after_commit/after_rollback callbacks.
        config.active_record.raise_in_transactional_callbacks = true
        #让bootstrap-sass和asset pipeline兼容
        config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
      end

    要使用bootstrap还需要在app/assets/stylesheets目录下创建一个css文件:custom.css.scss

    内容为:

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

    另外在app/assets/javascripts/application.js文件中添加一行

    //= require bootstrap

    这样才能使用bootstrap的javascript的组件。

    现在就可以开始使用bootstrap了。

  • 相关阅读:
    DapperExtensions 使用教程
    C#事件订阅及触发例子
    01、类与结构的区别
    内网信息搜集
    Anydesk拿下远程桌面
    C++对注册表的操作
    Linux下常见流编辑器的使用
    Typecho1.1反序列化漏洞复现
    Nmap脚本编写
    Github学习
  • 原文地址:https://www.cnblogs.com/jecyhw/p/5173850.html
Copyright © 2011-2022 走看看