Sign in
Log inSign up

How shape defined via position properties (top, left, right & bottom) different from width and height properties? Code snippet inside.

Abraham Earls's photo
Abraham Earls
·Sep 6, 2016

I have seen developers using two different ways to define height and width of fixed element.

Way 1 :

div{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
}

Way 2 :

div{
    position: fixed;
    height: 100%;
    width: 100%;
    background: #000;
}

Both the ways gave me same results. How are they different? CSS developers! Help please... ;)