两个上下分布的DIV之间有空隙,高手帮忙看看。

mardonma 2010-08-18 04:41:51
.top_fav{
height:80px;
background-image:url(../Img/top_fav.jpg);
text-align:right;}
.top_nav{
height:22px;
margin:0px auto;
background-image:url(../Img/top_nav.jpg);}
就这两个DIV上下之间有空隙,,不知道什么原因,,,高手指点下,在线等!!
...全文
1215 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
mardonma 2010-08-18
  • 打赏
  • 举报
回复
小弟谢谢各位前辈了,我准备去结贴咯,
www.xin2xin.com
我刚做好,,希望有困的朋友帮我看看要改进的地方,,
我是一个新手。请多指教!!
mardonma 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 ddcatlee 的回复:]
.top_nav ul {margin:0;}
[/Quote]
不好意思,刚才改错地方了,,你这个方法终于解决问题了,,O(∩_∩)O哈哈~
mardonma 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 ddcatlee 的回复:]
.top_nav ul {margin:0;}
[/Quote]
加上这个也不行,,唉

还有11楼说的框架我也取消了,可还是有空隙,,,我今天晕了一天了,,郁闷中……
ddcatlee 2010-08-18
  • 打赏
  • 举报
回复
.top_nav ul {margin:0;}
wqkjj 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lein_design 的回复:]

你的图片高度分别是80px、22px?
如果是的话 再看看你图片上是不是有留白...
[/Quote]

background-repeat缺省值不是repeat?
第二种嫌疑好像比较大些。
mardonma 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 lein_design 的回复:]
你试试楼上的吧
一般css都得写reset 百度一下很多的
然后就是你上面那个div里面的框架
那个也容易引起一些页面问题
[/Quote]
哦,谢谢指点,我刚按楼上的方法试了下,,果然是第一个DIV里面的内容引起的问题。。。我再试试
lein_design 2010-08-18
  • 打赏
  • 举报
回复
你试试楼上的吧
一般css都得写reset 百度一下很多的
然后就是你上面那个div里面的框架
那个也容易引起一些页面问题
东邪 2010-08-18
  • 打赏
  • 举报
回复
呃,页面做的不咋的,哈哈

不过你的问题出在ul的margin上

加入以下样式看看:

.top_fav p,
.top_nav ul { margin: 0; }
mardonma 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 e2ghost 的回复:]
楼主,这一段貌似有问题:

HTML code

.top_fav{
height:87px;
background-image:url(../Img/top_fav.jpg);
text-align:right;}
.top_nav{
height:22px;
margin:0px auto;
background-image:url(../Img/top_nav.jpg)……
[/Quote]

名称不一样啊,,一个是top_fav,一个是top_nav????
东邪 2010-08-18
  • 打赏
  • 举报
回复
sorry,是我看错
mardonma 2010-08-18
  • 打赏
  • 举报
回复
我给网址你们,,帮我看下,,今天瞎忙活一天了,这个问题还是不能解决
www.xin2xin.com
就是logo和导航栏之间,,在IE浏览器中有空隙,,360安全浏览器中没有空隙的,可以正常显示,。。。麻烦各位大侠了。。。
我现在把两个高度分布改成87和30了,,还是有空隙的,,这两个高度和对应图片的高度是一样的
东邪 2010-08-18
  • 打赏
  • 举报
回复
楼主,这一段貌似有问题:

.top_fav{
height:87px;
background-image:url(../Img/top_fav.jpg);
text-align:right;}
.top_nav{
height:22px;
margin:0px auto;
background-image:url(../Img/top_nav.jpg);}


怎么会有两个名称一样的样式?
另外,把两个有间距的div的内容全部清空,只留<div></div>看看有没有间距,如果没有了,那就是内容引起的,可能是p,或者ul的margin也有可能是其他原因。
natici 2010-08-18
  • 打赏
  • 举报
回复
加上这个css:

body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, hr{
margin:0;
padding:0;
}
mardonma 2010-08-18
  • 打赏
  • 举报
回复
就两个图片,,都是背景图片,应该不会影响两个DIV的高度呀,,,
mardonma 2010-08-18
  • 打赏
  • 举报
回复
部分HTML:
<!--头部开始-->
<div class="top_fav">
<p><a href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.xin2xin.com/');">设为主页</a>-<a href='#' onclick='window.external.AddFavorite("http://www.xin2xin.com/","【同城异性婚恋交友】")'>收藏本站</a></p>
<iframe width="140" height="46" allowtransparency="true" style="background-color=transparent" frameborder="0" scrolling="no" src="Code/tip_message.asp"></iframe>
</div>
<div class="top_nav">
<ul>
<li><a href="Index.asp"><span class="font_nav">首    页</span></a></li>
<li><a href="Code/PersonalCenter.asp"><span class="font_nav">个人中心</span></a></li>
<li><a href="Code/SearchMembers.asp"><span class="font_nav">搜索会员</span></a></li>
<li><a href="Code/NewMembers.asp"><span class="font_nav">最新会员</span></a></li>
<li><a href="Code/OnlineChat.asp"><span class="font_nav">在线聊天</span></a></li>
<li><a href="Code/EmotionalStory.asp"><span class="font_nav">情感故事</span></a></li>
</ul>
</div>
<!--头部结束-->

这是头部的DSS
.top_fav,.top_nav,.content,.footer
{
width:900px;
margin:0px auto;}
.top_fav{
height:87px;
background-image:url(../Img/top_fav.jpg);
text-align:right;}
.top_nav{
height:22px;
margin:0px auto;
background-image:url(../Img/top_nav.jpg);}
.top_nav ul{
list-style:none;}
.top_nav ul li{
width:98px;
height:20px;
margin-left:5px;
text-align:center;
float:left;}
.top_nav ul li:hover{
background-color:#FF66CC;}
.top_nav ul li:active{
background-color:#f00;}
东邪 2010-08-18
  • 打赏
  • 举报
回复
最好把完整的CSS以及HTML也贴出来。

可能是图片的高度小于div高度不符,也有可能是两个div之间有空格之类的,也有可能是有其他样式引起的……
lein_design 2010-08-18
  • 打赏
  • 举报
回复
你的图片高度分别是80px、22px?
如果是的话 再看看你图片上是不是有留白...

61,112

社区成员

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

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