How to center a span containing an image in a div

后端 未结 6 1722
傲寒
傲寒 2021-01-16 04:17

I have a main div (#homeGallery), in which i have a span(.imgClass) that is used to load one of a list of images. I need the image to be centered not only vertically but ho

6条回答
  •  爱一瞬间的悲伤
    2021-01-16 05:02

    You can try this code:-

       #homeGallery > .imgClass > img { 
    
                position:absolute;
                left:0;
                right:0;
                top:0;
                bottom:0;
                margin:auto;
                max-width:100%;
                max-height:100%;
                overflow:auto;
            }
    

提交回复
热议问题