作業を振り返ると
railsにBootstrapのgemをインストール
gemfile
1gem 'bootstrap-sass', '4.3.1'
トップページにnavbarを実装(こちらも4.3.1)
html.erb
1<nav class="navbar navbar-expand-lg navbar-light bg-light"> 2 <a class="navbar-brand" href="#">Navbar</a> 3 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" 4 aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> 5 <span class="navbar-toggler-icon"></span> 6 </button> 7 8 <div class="collapse navbar-collapse" id="navbarSupportedContent"> 9 <ul class="navbar-nav mr-auto"> 10 <li class="nav-item active"> 11 <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a> 12 </li> 13 <li class="nav-item"> 14 <a class="nav-link" href="#">Link</a> 15 </li> 16 <li class="nav-item"> 17 <a class="nav-link disabled" href="#">Disabled</a> 18 </li> 19 </ul> 20 <form class="form-inline my-2 my-lg-0"> 21 <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> 22 <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> 23 </form> 24 </div> 25 </nav>
既存のcssファイルはscssに変更済み
scss
1/* 2 * This is a manifest file that'll be compiled into application.css, which will include all the files 3 * listed below. 4 * 5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 * 8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 * files in this directory. Styles in this file should be added after the last require_* statement. 11 * It is generally better to create a new file per style scope. 12 * 13 */ 14 15@import "bootstrap-sprockets"; 16@import "bootstrap";
Bootstrapのインストールはおそらくできていると予想しています。
表示が崩れるのはasset関連かと思ったのですが原因がわかりませんでした。
ご教授頂ければ幸いです。
回答1件
あなたの回答
tips
プレビュー