如何将列从导航栏拉伸到 window 的底部?
How to stretch column from nav-bar to bottom of window?
我正在尝试将导航栏底部的一列拉伸到 window 的底部。
但我 运行 遇到了 2 种不愉快的情况。
列只占用其中的元素 space
列延伸 window 的整个高度但覆盖了部分导航栏
CSS
@media (min-width: 768px){
#left {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 25%;
overflow-y: scroll;
}
#right {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 75%;
}
}
View/Users/Show
<div class="container">
<div class="row">
<div class="tabbable">
<ul id="left" class="nav nav-pills nav-stacked col-md-3" style="padding-right: 50px;">
<%= render 'lists/form' %>
<% @lists.each do |list| %>
<%= content_tag :li do %>
<a href="#list-<%=list.id %>" data-toggle="tab"><%= list.name %></a>
<% end %>
<% end %>
</ul>
<div id="right" class="tab-content col-md-9">
</div>
</div>
</div>
Views/Layouts/Application.html.erb
<body>
<nav class="navbar navbar-inverse" style="margin: 0">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
</button>
<% if current_user %>
<%= link_to "App Name", @user, class: 'navbar-brand' %>
<% else %>
<%= link_to "App Name", root_path, class: 'navbar-brand' %>
<% end %>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
</div>
<% end %>
<%= yield %>
</body>
Bootstrap 和 rails 上的 ruby 正在使用。
我是网页设计新手。如果有人能指出我正确的方向,那就太棒了?
试试这个 css(jsfiddle 示例 here):
html, body, .container, .row, .tabbable{height:100%}
#left {
position: relative;
top: 0;
bottom: 0;
left: 0;
width: 25%;
overflow-y: scroll;
height: calc(100% - 20px);
}
#right {
position: relative;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 20px;
}
,其中 #right
div 应该在 #left
div 之前。
如果你想定位它们 absolute
,
html, body, .container, .row, .tabbable{height:100%}
#left {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 25%;
overflow-y: scroll;
height: calc(100% - 20px);
margin-top:20px;//height of #right
}
#right {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 20px;
}
, html div 的顺序并不重要。
我正在尝试将导航栏底部的一列拉伸到 window 的底部。
但我 运行 遇到了 2 种不愉快的情况。
列只占用其中的元素 space
列延伸 window 的整个高度但覆盖了部分导航栏
CSS
@media (min-width: 768px){
#left {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 25%;
overflow-y: scroll;
}
#right {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 75%;
}
}
View/Users/Show
<div class="container">
<div class="row">
<div class="tabbable">
<ul id="left" class="nav nav-pills nav-stacked col-md-3" style="padding-right: 50px;">
<%= render 'lists/form' %>
<% @lists.each do |list| %>
<%= content_tag :li do %>
<a href="#list-<%=list.id %>" data-toggle="tab"><%= list.name %></a>
<% end %>
<% end %>
</ul>
<div id="right" class="tab-content col-md-9">
</div>
</div>
</div>
Views/Layouts/Application.html.erb
<body>
<nav class="navbar navbar-inverse" style="margin: 0">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
</button>
<% if current_user %>
<%= link_to "App Name", @user, class: 'navbar-brand' %>
<% else %>
<%= link_to "App Name", root_path, class: 'navbar-brand' %>
<% end %>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
</div>
<% end %>
<%= yield %>
</body>
Bootstrap 和 rails 上的 ruby 正在使用。
我是网页设计新手。如果有人能指出我正确的方向,那就太棒了?
试试这个 css(jsfiddle 示例 here):
html, body, .container, .row, .tabbable{height:100%}
#left {
position: relative;
top: 0;
bottom: 0;
left: 0;
width: 25%;
overflow-y: scroll;
height: calc(100% - 20px);
}
#right {
position: relative;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 20px;
}
,其中 #right
div 应该在 #left
div 之前。
如果你想定位它们 absolute
,
html, body, .container, .row, .tabbable{height:100%}
#left {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 25%;
overflow-y: scroll;
height: calc(100% - 20px);
margin-top:20px;//height of #right
}
#right {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 20px;
}
, html div 的顺序并不重要。