How to make an image center (vertically & horizontally) inside a bigger div [duplicate]

问题:

This question already has answers here : 这个问题在这里已经有了答案
Closed 1 year ago . 1 年前关闭。

I have a div 200 x 200 px.我有一个 200 x 200 像素的 div。 I want to place a 50 x 50 px image right in the middle of the div.我想在 div 的中间放置一个 50 x 50 px 的图像。

How can it be done?怎么做?

I am able to get it centered horizontally by using text-align: center for the div.我可以使用text-align: center使其水平居中。 But vertical alignment is the issue..但垂直对齐是问题。


解决方案:

参考一: https://en.stackoom.com/question/1cyy
参考二: https://stackoom.com/question/1cyy
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章