Full viewport height scaling div just css no js… Possible?

后端 未结 3 1689
旧巷少年郎
旧巷少年郎 2021-02-02 12:55

Ok, I\'m trying to get a div to scale and the height is always the height of the viewport. I\'m going to link to my examples as it needs some explaining.

www.madmediabli

3条回答
  •  执念已碎
    2021-02-02 13:28

    You can use absolute positioning in a quite surprising way I surmise:

    div#element {
      position: relative;
    }
    
    img.vertical {
      position: absolute;
      top: 0; // no need for px or em 
      bottom: 0;
    }
    

    A compliant browser should try to respect both the top and bottom directives, actually managing a full height.

提交回复
热议问题