Making a div fit the initial screen

后端 未结 10 981
谎友^
谎友^ 2020-12-04 17:49

I want to make a div fit the initial height and width of a users screen.

I think the following crudely drawn diagram explain this better:

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 18:30

    You can do this completely with CSS too:

    html, body {
        margin: 0;
        padding: 0;
        min-height: 100%;
        width: 100%;
    }
    
    div {
        height: 100%;
        width: 100%;
    }
    

提交回复
热议问题