div居中,div图片居中代码

<!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=gb2312" />
<title>test.html</title>
</head>
<style>
.div_01{
margin:0 auto;
 text-align:center;
}
.div_01 img{

 
 margin:0 auto;
 vertical-align:middle;

}
</style>
<body>
<div class="div_01">
 <img src="http://www.baidu.com/img/baidu_logo.gif"/>
</div>
</body>
</html>

 

<!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=gb2312" />
<title>test.html</title>
</head>
<style>
.div_01{
 width:500px;
 height:500px;
 border:1px solid green;
 margin:0 auto;
 text-align:center;
}
.div_01 img{
 width:400px;
 height:400px;
 border:1px solid blue;
 margin:0 auto;
 vertical-align:middle;
 margin-top:48px;
}
</style>
<body>
<div class="div_01">
 <img src="http://www.baidu.com/img/baidu_logo.gif"/>
</div>
</body>
</html>

 

posted @ 2012-12-14 22:10  编写0513  阅读(223)  评论(0编辑  收藏  举报