Josecanalla
Josecanalla

Reputation: 515

Center vertically img responsive

Is there any method for vertically center a resposnive img without know 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 img responsive in different resolutions. So I can't use position attribute because the carousel has this attribute and bootstrap use display: table, so I can't use this.

I don't know the dimensions of the image because there are added dinamycally with PHP

I try to put a div container with fixed height attribute, this works great in large screens but in smaller resolutions this is not good because the img is very tall.

How can I do?

Upvotes: 0

Views: 1016

Answers (1)

Denise
Denise

Reputation: 43

Try adding the following to the CSS of the image:

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

Upvotes: 1

Related Questions