How to center the img in the div_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:11:48
Original
1107 people have browsed it


asdfasfasfasfdasdfdfasfsdf



The text is not centered, only the image is centered (not vertical)


Reply to discussion (solution)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server">    <title>xxxxxxx</title>    <style type="text/css">	<!--	div {	     text-align:center;		 width:500px; 		 height:500px; 		 border:1px solid #666666;	 	 }	 div span{	  margin:0px;	  padding:0px;	  display:block;	  margin-left:-290px;	  }	       	--></style></head><body><div> <span>asdfasfasfasfdasdfdfasfsdf</span> <img src="11.jpg"> </di  </body></html>
Copy after login

Keep moving forward...

Is it possible to fix the size of the div first
and use margin: auto to solve it?
I don’t know if it’s possible

See if it’s what you want. If not, look again. This mainly puts the image in one layer, and then centers the layer. It’s better to use different parameters. Change it.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style>#container{width:780px}#image{width:200px;margin:0 auto}</style></head><body><div id="container">123456789101112131415161718192021222324252627282930下面的图是一个200X150PX的图<div id="image"><img src="images/myphoto.jpg" width="200" height="150" /></div></div></body></html>
Copy after login

It’s probably like this, I haven’t tested it yet, you can adjust it again.


asdfasfasfasfdasdfdfasfsdf




This sentence is enough

Related labels:
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