dl dt dd怎么定位?
想实现一个图片,下面一个标题的list,不知道标题dt怎么定位在图片dd下?代码如下
<!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>无标题文档</title>
<style type="text/css">
.list{
width:400px;
height:70px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
.list dl{
float:left;
}
.list dt dd{
width:80px;
}
</style>
</head>
<body>
<div class="list">
<dl>
<dd><img src="http://avatar.profile.csdn.net/D/B/D/2_zh050317.jpg" /></dd>
<dt>1</dt>
</dl>
<dl>
<dd><img src="http://avatar.profile.csdn.net/D/B/D/2_zh050317.jpg" /></dd>
<dt>2</dt>
</dl>
<dl>
<dd><img src="http://avatar.profile.csdn.net/D/B/D/2_zh050317.jpg" /></dd>
<dt>3</dt>
</dl>
</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>无标题文档 </title> <style type="text/css"> .list{ width:400px; height:70px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto;text-align:center; } .list dl{ float:left; margin-left:10px;} .list dd{ width:auto; margin:0px;} .list dt{ margin:0px;} </style> </head> <body> <div class="list"> <dl> <dd> <img src="http://avatar.profile.csdn.net/D/B/D/2_zh050317.jpg" /> </dd> <dt>1 </dt> </dl> <dl> <dd> <img src="http://avatar.profile.csdn.net/D/B/D/2_zh050317.jpg" /> </dd> <dt>2 </dt> </dl> <dl> <dd> <img src="http://avatar.profile.csdn.net/D/B/D/2_zh050317.jpg" /> </dd> <dt>3 </dt> </dl> </div> </body> </html>
[解决办法]
2楼的代码简化一下:
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
直接写成:margin:0px auto;就行了