Make DIV cover 100% of viewport instead of 100% of Body

前端 未结 4 1952
死守一世寂寞
死守一世寂寞 2021-02-14 10:14

My post is in regards to http://www.thepostboard.net

I need to make the black box that is currently covering 100% of the viewport cover the entire page instead. You\'ll

4条回答
  •  耶瑟儿~
    2021-02-14 10:50

    The

    needs to be

    top: 0;
    left: 0;
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: red;
    

    It will then stay within the viewport's dimensions and "travel" with the scrollbar.

    Edit: it will only cover the entire viewport if is styled to

    margin: 0;
    padding: 0;
    

提交回复
热议问题