2015-10-14 32 views
0

我試圖從導航欄底部拉伸到窗口底部的列。如何將列從導航欄拉伸到窗口底部?

但我遇到了2種不良情況。

  1. 列只佔用盡可能多的空間元素裏面 enter image description here

  2. 柱延伸窗口的整個高度,但涵蓋了導航欄 enter image description here

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%; 
} 

}

查看/用戶/顯示

<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> 

瀏覽/設計/ 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> 

引導和Ruby on Rails正在使用。

我是網頁設計新手。如果有人能指引我朝正確的方向發展,那將會是驚人的。

回答

0

試試這個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格。

如果你想給他們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來這並不重要。