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

WBOY
Release: 2016-06-24 12:20:56
Original
1699 people have browsed it

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>
Copy after login


<div>    <img src="0.png" /></div>
Copy after login

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.



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template