div +css高手请进,谢谢
下面是我写的代码,请问thisisheader和thisismenu下面的空行该怎么去除呢?我想让他们紧贴着。代码:<!DOCTYPEhtmlPUBLIC"-//W3C/...
下面是我写的代码,请问 this is header 和 this is menu 下面的空行该怎么去除呢?
我想让他们紧贴着。
代码:
<!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>div测试</title>
<style>
body{ margin:0px;}
#container{width:900px;margin:0px auto;}
#header{height:100px; background-color:#FF0000;margin:0px;}
#menu{height:20px; background-color: #999999;margin:0px;}
#sidebar{width:250px;float:left; background-color:#FFFF00;margin:0px;}
#content{width:630px; float:right; background-color: #9966CC;margin:0px;}
#foot{height:100px; background-color:#FF00FF}
#t{width:100px; background-color:#0033FF}
#g{width:80px; background-color:#996600}
.clearfloat{clear:both; height:0px; line-height:0px;}
</style>
</head>
<body>
<div id="container">
<div id="header"> this is header</div>
<br class="clearfolat"/>
<div id="menu">this is menu</div>
<br class="clearfolat"/>
<div id="sidebar">this is sidebar</div>
<div id="content"><p>this is content</p>
<p>this is content</p><p>this is content</p>
<div style="background-color:#FF66CC">
<div id="t">ttttt</div>
<div id="g">gggggg</div>
</div>
<p>this is content</p><p>this is content</p>
<p>this is content</p><p>this is content</p>
</div>
<br class="clearfloat"/>
<div id="foot">this is foot</div>
</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=utf-8" />
<title>div测试</title>
<style>
body{ margin:0px;}
#container{width:900px;margin:0px auto;}
#header{height:100px; background-color:#FF0000;margin:0px;}
#menu{height:20px; background-color: #999999;margin:0px;}
#sidebar{width:250px;float:left; background-color:#FFFF00;margin:0px;}
#content{width:630px; float:right; background-color: #9966CC;margin:0px;}
#foot{height:100px; background-color:#FF00FF}
#t{width:100px; background-color:#0033FF}
#g{width:80px; background-color:#996600}
.clearfloat{clear:both; height:0px; line-height:0px;}
</style>
</head>
<body>
<div id="container">
<div id="header"> this is header</div>
<br class="clearfolat"/>
<div id="menu">this is menu</div>
<br class="clearfolat"/>
<div id="sidebar">this is sidebar</div>
<div id="content"><p>this is content</p>
<p>this is content</p><p>this is content</p>
<div style="background-color:#FF66CC">
<div id="t">ttttt</div>
<div id="g">gggggg</div>
</div>
<p>this is content</p><p>this is content</p>
<p>this is content</p><p>this is content</p>
</div>
<br class="clearfloat"/>
<div id="foot">this is foot</div>
</div>
</body>
</html> 展开
6个回答
展开全部
this is header 和 this is menu 下面的空行解决:
<br class="clearfolat"/>
<div id="menu">this is menu</div>
<br class="clearfolat"/>
br的意思就是换行。在br里面加css那肯定也要继承br的属性,所以会有空行
一般的不用div的样式最好是<span>
所以呢解决方法就是
把<br>改成<span>
这样写
<span class="clearfolat"/></span>
<div id="menu">this is menu</div>
<span class="clearfolat"/></span>
记住要有闭合标签的。
<br class="clearfolat"/>
<div id="menu">this is menu</div>
<br class="clearfolat"/>
br的意思就是换行。在br里面加css那肯定也要继承br的属性,所以会有空行
一般的不用div的样式最好是<span>
所以呢解决方法就是
把<br>改成<span>
这样写
<span class="clearfolat"/></span>
<div id="menu">this is menu</div>
<span class="clearfolat"/></span>
记住要有闭合标签的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
问题解决,代码如下:
<!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>div测试</title>
<style>
body{ margin:0px;}
#container{width:900px;margin:0px auto;}
#header{height:100px; background-color:#FF0000;margin:0px;}
#menu{height:20px; background-color: #999999;margin:0px;}
#sidebar{width:250px;float:left; background-color:#FFFF00;margin:0px;}
#content{width:630px; float:right; background-color: #9966CC;margin:0px;}
#foot{height:100px; background-color:#FF00FF}
#t{width:100px; background-color:#0033FF}
#g{width:80px; background-color:#996600}
.clearfloat{clear:both; height:0px; line-height:0px;}
div.clearfolat{clear:both; height:0; line-height:0;}
</style>
</head>
<body>
<div id="container">
<div id="header"> this is header</div>
<div class="clearfolat"></div>
<div id="menu">this is menu</div>
<div class="clearfolat"></div>
<div id="sidebar">this is sidebar</div>
<div id="content"><p>this is content</p>
<p>this is content</p><p>this is content</p>
<div style="background-color:#FF66CC">
<div id="t">ttttt</div>
<div id="g">gggggg</div>
</div>
<p>this is content</p><p>this is content</p>
<p>this is content</p><p>this is content</p>
</div>
<br class="clearfloat"/>
<div id="foot">this is foot</div>
</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=utf-8" />
<title>div测试</title>
<style>
body{ margin:0px;}
#container{width:900px;margin:0px auto;}
#header{height:100px; background-color:#FF0000;margin:0px;}
#menu{height:20px; background-color: #999999;margin:0px;}
#sidebar{width:250px;float:left; background-color:#FFFF00;margin:0px;}
#content{width:630px; float:right; background-color: #9966CC;margin:0px;}
#foot{height:100px; background-color:#FF00FF}
#t{width:100px; background-color:#0033FF}
#g{width:80px; background-color:#996600}
.clearfloat{clear:both; height:0px; line-height:0px;}
div.clearfolat{clear:both; height:0; line-height:0;}
</style>
</head>
<body>
<div id="container">
<div id="header"> this is header</div>
<div class="clearfolat"></div>
<div id="menu">this is menu</div>
<div class="clearfolat"></div>
<div id="sidebar">this is sidebar</div>
<div id="content"><p>this is content</p>
<p>this is content</p><p>this is content</p>
<div style="background-color:#FF66CC">
<div id="t">ttttt</div>
<div id="g">gggggg</div>
</div>
<p>this is content</p><p>this is content</p>
<p>this is content</p><p>this is content</p>
</div>
<br class="clearfloat"/>
<div id="foot">this is foot</div>
</div>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<br>标签即表示换行.
你可以改成别的 如<div class="clearfloat"></div>
即可!
你可以改成别的 如<div class="clearfloat"></div>
即可!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<br class="clearfolat"/>去掉,或者改为<div class="clearfloat">
或者把这段并到里面<div id="header"> this is header<br class="clearfolat"/></div>这样问题就解决了
或者把这段并到里面<div id="header"> this is header<br class="clearfolat"/></div>这样问题就解决了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把这个“ <br class="clearfolat"/>”都删掉
<br />是换行的意思,一般在文字里面用。
<br />是换行的意思,一般在文字里面用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询