<!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>
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>
It’s probably like this, I haven’t tested it yet, you can adjust it again.