Center vertically img responsive

Is there any method for vertically centering resposnive img without specifying height and width and without using display: table or position: absolute / relative?

The specific problem is that I am using bootstrap carousel and I want to center the img responsively at different resolutions. So I cannot use the position attribute because the carousel has this attribute and loading screen: table, so I cannot use that.

I don't know the dimensions of the image, because the dynamic ones are added with PHP

I'm trying to fit a div container with a fixed height attribute, this works great on large screens, but at lower resolutions it's not good because the img is very tall.

How can i do this?

0


source to share


1 answer


Try adding the following to your CSS:



margin-right:auto;
margin-left:auto;
display:block;
position:relative;

      

+2


source







All Articles