Html 如何让侧边栏垂直填充空间?

Html 如何让侧边栏垂直填充空间?,html,css,Html,Css,我有一个非常简单的布局,看起来像这样 其代码如下所示: <!DOCTYPE html> <html> <HEAD> <LINK href="mystyle.css" title="compact" rel="stylesheet" type="text/css"> </HEAD> <body> <div id="wrap"> <div id="header"> <

我有一个非常简单的布局,看起来像这样

其代码如下所示:

<!DOCTYPE html>
<html>
<HEAD>
    <LINK href="mystyle.css" title="compact" rel="stylesheet" type="text/css">
  </HEAD>
<body>

<div id="wrap">

    <div id="header">
    <p> Im the header. </p> 
    </div>

    <div id="nav">
    <p> Im the nav. </p> 
    </div>

    <div id="sidebar">
    <p> sidebar here </p> 
    <p> sidebar here </p>
    <p> sidebar here </p>
    <p> sidebar here </p>
    <p> sidebar here </p>
    <p> sidebar here </p>
    <p> sidebar here </p>
    <p> sidebar here </p>
    <p> sidebar here </p>
    </div>

    <div id="main">
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    <p> im the main </p> 
    </div>

    <div id="footer">
    <p> footer </p> 
    </div>
</div>

<body> 


</html>
现在我不知道为什么我不能让粉色的are/侧边栏垂直填充所有空间,直到橙色的页脚?

示例:

1) 将
#侧栏
内容附加到
#主
元素

2) 将
位置:相对
添加到
#main
元素

3) 将此额外代码添加到css文件:

#sidebar {
  height:100%;
  position:absolute;
  right:0;
  top:0;
  background:pink;
}
例如:

1) 将
#侧栏
内容附加到
#主
元素

2) 将
位置:相对
添加到
#main
元素

3) 将此额外代码添加到css文件:

#sidebar {
  height:100%;
  position:absolute;
  right:0;
  top:0;
  background:pink;
}

您也可以给#以粉红色包装,并将#主宽度设置为~70%,这通常用作解决方法

现在你的边框也是粉红色的,因为包裹里有填充物,但你可以随意玩,直到它符合你的需要

#wrap
{ 
    width: 100%; 
    background-color:pink; 
    padding: 10px; 
}

#main 
{ 

    width:70%; 
    background:green; 
    padding: 10px; 

}

示例:

您还可以给#以粉红色包装,并将#主宽度设置为~70%,这通常用作解决方法

现在你的边框也是粉红色的,因为包裹里有填充物,但你可以随意玩,直到它符合你的需要

#wrap
{ 
    width: 100%; 
    background-color:pink; 
    padding: 10px; 
}

#main 
{ 

    width:70%; 
    background:green; 
    padding: 10px; 

}
示例:

海利先生纸袋

试试看。。。首先创建一个类似于此链接的图像

在css中

以下是关于相等列的4个教程:

祝你好运

哈雷先生的纸袋

试试看。。。首先创建一个类似于此链接的图像

在css中

以下是关于相等列的4个教程:

祝你好运