Home >Web Front-end >HTML Tutorial >urgent! ! How to center an image! _html/css_WEB-ITnose
I have a square div frame, which does not have a fixed px and is written with Baxian%. Then I want to put a rectangular picture in it and then center it up and down. Can you do it?
What to do? Urgent ~ ~
Also, this rectangular image needs to be compressed to the height of the square
margin:auto;
The image must have a width
If the height is known, like this:
<style type="text/css"> div { text-align:center; outline:1px solid #ccc; height:200px; line-height:200px; } </style>
<div> <img src="0.png" /></div>
Method 1: You can use body{text- align:center} In this case, everything is customized.
Method 2: Use align="center" in img
Puke International Stay.
2d20141fd3df61e23e6da7f45136680b
98264935398820f481e6cda9ceba02bc
16b28748ea4df4d9c2150843fecfba68