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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章