html - 了解 div

标签 html css

我很难理解 div。

我想让“导航”面板根据需要垂直展开。我遇到的第二个问题是我似乎无法让填充工作。我所做的任何更改往往会导致“section”div 低于“nav”div。

请参阅下面的 jsfiddle 和代码。

提前致谢。

https://jsfiddle.net/s59cwy9s/

<div id="container">
    <div id="nav">          
       test    
    </div>
    <div id="section">          
        test    
    <br><br><br><br>        
        test        
    <br><br><br><br>        
        test        
    </div>     
</div>

#container
{    
    width: 1156px;
    margin-top: 0;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 5px 5px 10px rgb(0,0,0);
    position: relative;
    background-color: transparent; 
    height: auto;        
}

#header 
{
    background-color:black;
    color:white;
    text-align: center;
    padding:5px;    
}

#nav 
{    
    line-height:30px;
    background-color:#eeeeee;
    min-height: 100px;
    min-width: 80px;
    float:left;
    padding: 15px;
    display: inline-block; 
    height: auto;    
}

#section 
{    
    /*float: none;*/
    padding: 10px;
    display: block;
    /*position: absolute;*/
    /*overflow: auto;*/
    background-color: white;
    width: auto;
    height: auto;      
}

最佳答案

这可能是因为您的名称栏没有完全跨越网页的高度。为导航栏尝试 height :100% 之类的东西。它可能会成功。

关于html - 了解 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32800686/

相关文章:

html - 选择在 FireFox 中不显示为正常

html - 为什么我的列没有扩大到容器高度?

javascript - 如何为可移动 DIVS 创建显示更多/更少按钮

html - 如何创建具有不寻常结构的表(html、css、js?)

javascript - 影响相邻元素背景颜色的不透明度过渡

javascript - 如何使用 jQuery 等待 CSS3 过渡结束?

css - 如何使用 CSS 根据需要在图像周围绘制边框?

html - 段落元素的背景扩展以填充表格

html - 带线段的 CSS 半圆

jquery - 添加和删​​除 css 的切换按钮