CSS: height- fill out rest of div?

前端 未结 7 1991
星月不相逢
星月不相逢 2020-12-10 10:13

i wonder if this is possible with simple css or if i have to use javascript for this?

i have a sidebar on my website. a simple div#sidbar it\'s normally about 1024px

7条回答
  •  盖世英雄少女心
    2020-12-10 10:57

    If you know the exact height of #widget (100px in your case), you can avoid using JavaScript by using absolute positioning:

    #sidebar
    {
    height: 100%;
    width: ...;
    position: relative;
    }
    
    .widget
    {
    height: 100px;
    }
    
    #rest
    {
    position: absolute;
    left: 0;
    width: 100%;
    top: 200px;
    bottom: 0;
    }
    

提交回复
热议问题