CSS div does not move in the middle

I am creating my own website, but for some reason I cannot move the black box to the middle of the screen, please, could you help me. I have to do it on JSFiddle because I don’t have enough RP to show screenshots here.

Please view this link to view my code:

http://jsfiddle.net/xiiJaMiiE/LfWBn/4/

#white_box {
position:absolute;
margin:auto 0;
min-width:80%;
max-width:100%;
height:85%;
top:0%;
background:black;
z-index:1;
width:80%;
}

Thanks in advance!

+4
source share
3 answers

If widthalways 80%, just shift the left half of the receiver width:

left:10%;

Check out this demo http://jsfiddle.net/LfWBn/7/

+5
source

Hope this works:

#white_box {
        position:absolute;
        margin:auto 0;
        min-width:80%;
        max-width:100%;
        height:85%;
        top:7%;
        left:10%;
        background:black;
        z-index:1;
        width:80%;
    }
0
source

, : margin: 20px;

-1

Source: https://habr.com/ru/post/1524742/


All Articles