2016-05-07 50 views
0

所以,這是我的主頁:引導NAV採取100%的高度

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <title>TITLE</title> 

    <link href="/resources/css/bootstrap.css" rel="stylesheet" type="text/css"/> 
    <link href="/resources/css/myStyle.css" rel="stylesheet" type="text/css"/> 
</head> 

<body> 

<jsp:include page="parts/header.jsp"/> 
<jsp:include page="parts/leftMenu.jsp"/> 

<h2>WELCOME IN MY STORE!!!</h2> 
<h2>WELCOME IN MY STORE!!!</h2> 
... 
<h2>WELCOME IN MY STORE!!!</h2> 


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
<script src="/resources/js/bootstrap.min.js"></script> 

</body> 
</html> 

正如你可以看到我在這裏包含文件「leftMenu.jsp」,其中我加入,我希望出現動態幾類在左側邊欄。這是文件:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ page contentType="text/html;charset=UTF-8" language="java" %> 

<div class="nav nav-pills nav-stacked col-lg-1"> 

    <c:forEach items="${categoryNames}" var="category"> 
     <c:choose> 
      <c:when test="${category.getSubCategories().size()>'0'}"> 
       <li><a data-toggle="collapse" href="#${category.getName().toLowerCase()}">${category.getName()}<span 
         class="caret"/></a></li> 
       <ul id="${category.getName().toLowerCase()}" class="collapse"> 
        <c:forEach items="${category.getSubCategories()}" var="subCategory"> 
         <li><a href="category/${category.getId()}/${subCategory.getId()}">${subCategory.getName()}</a> 
         </li> 
        </c:forEach> 
       </ul> 
      </c:when> 
      <c:otherwise> 
       <li><a href="category/${category.getId()}/0">${category.getName()}</a></li> 
      </c:otherwise> 
     </c:choose> 
    </c:forEach> 

</div> 

我想這個側邊欄承擔全部可用高度,所以我嘗試添加該myStyle.css:

.nav { 
    height: 100%; 
    min-height: 100%; 
} 

但它不工作,我怎麼想。

enter image description here

我怎樣才能解決這個問題?

回答

1

嘗試設置position: absolute;
這裏是工作的解決方案https://jsfiddle.net/L24x1o20/2/

+0

它沒有工作:/ –

+0

嗯它的工作在我的引導。使用'min-height:100%;'和'postion:absolute;'''.navbar'類。你可以在jsfiddle中設置它嗎? – jakob

+0

我試圖在jsfiddle做到這一點,但它在另一個https://jsfiddle.net/L24x1o20/ –