日期:2014-05-17  浏览次数:20625 次

一个关于UL li 中DIV的问题
一个大DIV然后里面有UL li,在每个li当中我要插入一副图片和一段文字,要求插入的图片和文字属于同一个DIV,图片在文字的上方,上方图片和下方文字的宽度相等,上方图片需要居中,下方的文字也需要居中,谁能给个代码参考一下,万分感谢!

------解决方案--------------------
HTML code
<html>
<head>
<title></title>
<style type="text/css">
li {float: left; margin-bottom: 10px; border:1px solid gray;width: 202px;}
img {margin:10px 10px 0 10px;background:red;width:180px;height:180px;border:1px solid blue;}
p {padding: 10px;line-height:24px;font-size:12px;color:yellow;text-align:center;}
</style>
</head>
<body>
<ul style="margin: 0 auto; width: 204px;overflow:hidden;">
    <li>
        <img src="" />
        <p>123123123123123<br/>123123123123123<br/>123123123123123<br/></p>
    </li>
    <li>
        <img src="" />
        <p>123123123123123<br/>123123123123123<br/>123123123123123<br/></p>
    </li>
</ul>
</body>
</html>

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title> New Document </title>
<style>
 *{margin:0;padding:0;}
</style>
</head>

<body >
<div class="">
 <dl>
<dt style="width:60px; height:45px; background:red;"><img src="../images/im.jpg"></dt>
<dd>我在图片的下面</dd>
 </dl>
</div>
</body>
</html>
我的觉得用dl实现更加符合html语义化;