Home >Web Front-end >HTML Tutorial >urgent! ! How to center an image! _html/css_WEB-ITnose

urgent! ! How to center an image! _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:20:561736browse

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 ~ ~


Reply to the discussion (solution)

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn