我已经阅读了大约6-8个关于同一问题的帖子,但我无法在我的上下文中找到任何可行的解决方案。
我遇到的问题是我有一个透明的导航栏和全屏jumbotron,但我无法让jumbotron进入导航栏。换句话说,我试图让我的jumbotron完全全屏,然后将导航栏放在它上面。
我做了什么
我需要帮助来提供响应式解决方案来处理这个问题。我正在使用Ruby on Rails。这是我的application.html.erb,其中包含我的导航栏:
<!DOCTYPE html>
<html>
<head>
<title>Light Bulb</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= stylesheet_link_tag 'application', 'https://fonts.googleapis.com/css?family=Lobster+Two', media: 'all', 'data-turbolinks-track' => true %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="navbar transparent navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav-collapse">
<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="/">Light Bulb</a>-->
<%= link_to root_path, class: 'navbar-brand nav-font' do %>
<i class="fa fa-lightbulb-o" id="fa-size"></i>
Light Bulb
<% end %>
</div>
<div class="collapse navbar-collapse" id="main-nav-collapse">
<div class = "nav navbar-nav navbar-right">
<% if current_user %>
<%= button_to "Sign Out", destroy_user_session_path, method: :delete, class: "btn btn-primary navbar-btn" %>
<% else %>
<%= link_to "Log In", new_user_session_path, class: "btn btn-primary navbar-btn", method: :get %>
<%= link_to "Sign Up", new_user_registration_path, class: "btn btn-success navbar-btn", method: :get %>
<% end %>
</div>
<% if controller_name === "pages" && action_name === "homepage" %>
<ul class="nav navbar-nav navbar-right nav-font">
<% else %>
<ul class="nav navbar-nav navbar-right nav-font-inverted">
<% end %>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Contact", new_contact_path %></li>
</ul>
</div>
</div>
</nav>
<% if controller_name === "pages" && action_name === "homepage" %>
<%= yield %>
<% else %>
<div class="container">
<% flash.each do |key, value| %>
<%= content_tag :div, value, class: "alert alert-#{key}" %>
<% end %>
<%= yield %>
</div>
<% end %>
</body>
</html>
这是我的homepage.html.erb,有我的jumbotron:
<div class="jumbotron text-center">
<div class="container">
<h1>Welcome to Light Bulb</h1>
<h3>Turn your ideas into reality!</h3>
</div>
</div>
这是我的CSS文件:
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome-sprockets";
@import "font-awesome";
.navbar.transparent.navbar-inverse {
border-width: 0px;
-webkit-box-shadow: 0px 0px;
box-shadow: 0px 0px;
background-color: rgba(0,0,0,0.0);
background-image: -webkit-gradient(linear, 50.00% 0.00%, 50.00% 100.00%, color-stop( 0% , rgba(0,0,0,0.00)),color-stop( 100% , rgba(0,0,0,0.00)));
background-image: -webkit-linear-gradient(270deg,rgba(0,0,0,0.00) 0%,rgba(0,0,0,0.00) 100%);
background-image: linear-gradient(180deg,rgba(0,0,0,0.00) 0%,rgba(0,0,0,0.00) 100%);
margin-bottom: 0px;
}
.jumbotron {
margin-top: 0px;
margin-bottom: 0px;
}
.navbar-brand.nav-font {
color: black;
font-size: 1.7em;
font-family: "Lobster Two"
}
.navbar-brand.nav-font:hover {
color: black;
}
.navbar-nav.nav-font li a {
color: black;
text-align: center;
font-family: "Lobster Two";
font-size: 1.6em;
// padding-left: 2em;
// padding-right: 2em;
width: 10em;
height: 3em;
display: block;
line-height: 35px;
-o-transition:.6s;
-ms-transition:.6s;
-moz-transition:.6s;
-webkit-transition:.6s;
transition: .6s;
}
.navbar-nav.nav-font-inverted li a {
color: red;
text-align: center;
font-family: "Lobster Two";
font-size: 1.6em;
// padding-left: 2em;
// padding-right: 2em;
width: 10em;
height: 3em;
display: block;
line-height: 35px;
-o-transition:.6s;
-ms-transition:.6s;
-moz-transition:.6s;
-webkit-transition:.6s;
transition: .6s;
}
#fa-size {
font-size: 1.7em;
}
.navbar-nav.nav-font li a:hover {
color: white;
background: rgba(0,0,0, 0.7);
}
.contact-padding {
margin-top: 5em;
}
.form-dimensions-contact {
height: 40px;
}
.contact-form-border {
border-radius: 25px;
// color: rgba(130, 130, 130, 0.5);
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
// opacity: 0.9;
background: rgba(255,255,255,0.2);
}
.jumbotron{
height: 100vh;
}
答案 0 :(得分:1)
尝试将 / nav 更改为 / div ,因为您在 .navbar 中使用div进行打开