图片在div中居中显示
要求:将图片在div中居中显示。
实现方法:
在div中设置样式background的值为 url(图片地址) no-repeat center
代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head><title> New Document </title><meta name="Generator" content="EditPlus"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Description" content=""> </head> <body><div id="outer" style="width:600px;height:600px;border:1px red solid;background:url(nv.jpg) no-repeat center">居中显示例子</div> </body></html>
效果如下:
http://dl.iteye.com/upload/attachment/477457/233263a7-c751-38b6-834e-b8d66484bb03.png
页:
[1]