Centering an image that is in an anchor tag

前端 未结 5 1872
迷失自我
迷失自我 2021-01-23 17:50

I have an image in an anchor tag, and I need to center it.

I have managed to do so using this technique that I just came across messing about in the DOM inspector: http:

5条回答
  •  难免孤独
    2021-01-23 18:36

    use -ms-flexbox supported by all browser. DEMO

    #container{
        width: 600px;
        height:600px;
        background: red;
    }
    
    .centre{ 
    height: 100%;
        width:100%;
    
    /* Internet Explorer 10 */
    display:-ms-flexbox;
    -ms-flex-pack:center;
    -ms-flex-align:center;
    
    /* Firefox */
    display:-moz-box;
    -moz-box-pack:center;
    -moz-box-align:center;
    
    /* Safari, Opera, and Chrome */
    display:-webkit-box;
    -webkit-box-pack:center;
    -webkit-box-align:center;
    
    /* W3C */
    display:box;
    box-pack:center;
    box-align:center; 
    }
    

提交回复
热议问题