首页  >  文章  >  web前端  >  怎样让div中的img居中_html/css_WEB-ITnose

怎样让div中的img居中_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 12:11:481087浏览


asdfasfasfasfdasdfdfasfsdf
怎样让div中的img居中_html/css_WEB-ITnose


文字不居中,仅仅图片居中(非垂直)


回复讨论(解决方案)

<!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" alt="怎样让div中的img居中_html/css_WEB-ITnose" > </di  </body></html>

继续向前····

是不是可以先把div固定大小了
使用margin:auto来解决呢?
我也不知道可不可以

看看是不是你想要的,不是的话再看,这个主要让图片在一个层中,然后对这个层做居中.不如参数不一样自己改改.

<!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"    style="max-width:90%"  style="max-width:90%" / alt="怎样让div中的img居中_html/css_WEB-ITnose" ></div></div></body></html>

大概这样,没有测试过,你再调调。


 
asdfasfasfasfdasdfdfasfsdf 

怎样让div中的img居中_html/css_WEB-ITnose
 

 

 
这一句就够了
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn