css3:如何将高度100%放在静态/相对(无绝对定位)div上?(css3 : how to put height 100% on a static/relative (no absolute po

编程入门 行业动态 更新时间:2024-10-11 11:19:43
css3:如何将高度100%放在静态/相对(无绝对定位)div上?(css3 : how to put height 100% on a static/relative (no absolute positionned) div?)

我有一个容器和2个div:1个标题(如果我添加一些行,它的高度应该是空闲的)和userList。 我希望userList具有容器的高度:任何想法如何? (没有JS解决方案,如果没有位置则更好:使用asbolute)

#container {
	width: 300px;
	height:400px;
	background-color: #FF0000;
}
#header{
	background-color: #FFF500;
}
#userList {
	background-color: #00FF00;
	width:290px;
	height: 100%;
	overflow-y:auto;
} 
  
<div id="container">
	<div id="header">line1<br>line2<br>line3</div>
    <div id="userList">
    	line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>
        line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>
            </div>
</div> 
  
 

I have a container and 2 divs inside: 1 header (whose height should be free if I add some lines) and an userList. I want the userList to have the height of the container : any idea how ? (no JS solution, better if no position: asbolute used)

#container {
	width: 300px;
	height:400px;
	background-color: #FF0000;
}
#header{
	background-color: #FFF500;
}
#userList {
	background-color: #00FF00;
	width:290px;
	height: 100%;
	overflow-y:auto;
} 
  
<div id="container">
	<div id="header">line1<br>line2<br>line3</div>
    <div id="userList">
    	line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>
        line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>
            </div>
</div> 
  
 

更多推荐

height,userList,container,高度,JS,电脑培训,计算机培训,IT培训"/> <meta name=&qu

本文发布于:2023-08-04 03:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408969.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:放在   如何将   静态   高度   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!