I want to center an image of unknown width/height on a page, while making sure that it shrinks if it is bigger than the page (i.e. use max-width
/max-height
).
I tried using the display:table-cell
method, but max-width
is ignored in Firefox for all elements within elements declared with display:table-cell
. Is there a way to vertically center a variable-height element without using display:table-cell
?
I can change the mark up. JavaScript is acceptable, but I cannot use JQuery (or any other JS library).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…