请教个dl dt dd问题,定位上出现的问题,谢谢

nomis827 2014-05-24 11:36:02




<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
#mydiv {
height: 400px;
width: 800px;
}
#mydiv2 {
background-color: #0C9;
height: 400px;
width: 400px;
float:left;
}
#mydiv3 {
background-color:#F30;
height: 400px;
width: 400px;
float:left;
}

#mydiv2 dl{
height:30px;
background-color:#0FF;
margin:0px;
padding: 0px;
}
#mydiv #mydiv2 dl dd {
padding: 0px;
}



#mydiv2 dl dd ul {
background-color: #FFF;
list-style-type: none;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
-->
</style>
</head>

<body>
<div id="mydiv">
<div id="mydiv2">
<dl>
<dt> 通知公告</dt>
<dd>
<ul>
<li>1dsfsfsd</li>
<li>2sdffsfsf</li>
<li>3sdfdsfsdfs</li>
<li>4sdfsfsdf</li>
</ul>
</dd>
</dl>
</div>
<div id="mydiv3"></div>
</div>
</body>
</html>



我在dl中的dt 上写标题,在dd里嵌套一个ul li列表

我已经把ul的 margin padding都设为0了。但目前定位仍有问题,不能左对齐,而且 ul是包含在dd里,为什么会高于其上边界呢。
...全文
304 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
去除默认样式
ul,dl,dd{margin:0;padding:0;}
nomis827 2014-05-24
  • 打赏
  • 举报
回复
额,低级错误,见笑见笑
  • 打赏
  • 举报
回复
<dt><dt> <dd><dd> =》 <dt></dt> <dd></dd> 注意闭合,你应该了解前端规范
nomis827 2014-05-24
  • 打赏
  • 举报
回复


鸡哥,还有个问题,我设置 dt的高度,为什么结果比设定高度大了一倍??



<!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 type="text/css">
<!--
#maindiv {
background-color: #CCC;
height: 200px;
width: 600px;
}
.bandiv {
background-color: #FFF;
height: 200px;
width: 300px;
float:left;
}

.bandiv dl dt{
background-color:#F00;
width:300px;
height:30px;
}

ul,dl,dd,dt{
margin:0px;
padding:0px;
}
-->
</style>
</head>

<body>
<div id="maindiv">

<div class="bandiv">
<dl>
<dt><dt>
<dd><dd>
</dl>
</div>

<div class="bandiv"></div>
</div>
</body>
</html>
nomis827 2014-05-24
  • 打赏
  • 举报
回复
研究发现是 dd的margin没设造成的。 貌似 dl的padding作用不到dd上
nomis827 2014-05-24
  • 打赏
  • 举报
回复
鸡哥,我想请问 #mydiv2 dl{ height:30px; background-color:#0FF; margin:0px; padding: 0px; } #mydiv2 dl dd ul { 。。。。。。 margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; } 我这代码里都间接的设置这几项为0为什么不生效呢 像你这样直接设置怎么就生效了??

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧