I'm migrating my static HTML/CSS/JS site to a Rails app. I'm using Bootstrap 4, and all the Bootstrap 4 functionality and CSS classes were working on the static page. Now in the Ruby app, the navbar isn't showing up at all.
Am I missing a gem file? Is there a specific way to embed the style tags that I'm doing wrong?
my gem file:
gem 'rails', '~> 5.0.5'
gem 'sqlite3'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'bootstrap', '~> 4.0.0.beta'
gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2'
gem "autoprefixer-rails"
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a
debugger console
gem 'byebug', platform: :mri
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
my javascript requires:
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require_tree .
my custom CSS:
.navbar-custom {
border-radius: 0px;
z-index: 16;
box-shadow: 0 2px 3px 0 rgba(0,0,0, .4);
}
my application.html.erb head:
<%= stylesheet_link_tag 'application', media: 'all', 'data-
turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track':
'reload' %>
my application.html.erb navbar:
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse navbar-custom">
<div class="container-fluid d-inline-flex">
<button type="button" class="navbar-toggler navbar-toggler-right" data-toggle="collapse" data-target="#navbarSupportedContent" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
<a class="navbar-brand justify-cotent-start" href="#home"><%= image_tag "logo.png", size:"50" %></a>
</button>
<a class="navbar-brand justify-cotent-start" href="#home"><%= image_tag "logo.png", size:"50" %></a>
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="nav navbar-nav ml-auto" style="float: right">
<li class="nav-item"><a class="nav-link" href="#about">about</a></li>
<li class="nav-item"><a class="nav-link" href="#events">events</a></li>
<li class="nav-item"><a class="nav-link" href="#gallery">gallery</a></li>
<li class="nav-item"><a class="nav-link" href="#music">music</a></li>
<li class="nav-item"><a class="nav-link" href="#press-kit">press kit</a></li>
<li class="nav-item"><a class="nav-link" href="#contact">contact</a></li>
</ul>
</div>
</div>
</nav>
I had this same problem and found that it was fixed by changing
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse navbar-custom">
to
<nav class="navbar navbar-expand-md navbar-dark bg-dark navbar-custom">
You might be looking at documentation for a different version. The documentation for 4.0.0beta is found here https://getbootstrap.com/docs/4.0/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.