<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title><style type="text/css">#menu {background-color:#ffff99;height:200px; float:left;width:100px;margin-top:0px;}h2 {margin-bottom:0px; font-size:14px;}#container{width:500px;}h1{margin-bottom:0px;text-decoration:0px;font-family:Georgia, "Times New Roman", Times, serif;font-size:40px;color:#90DA11;}#content{float:right;background-color:#6FF;width:400px;height:200px;}#footer{background-color:#6F3;clear:both;text-align:center;}p{line-height:0px;margin-top:5px;text-indent:20px;color:#000;font-family:Arial, Helvetica, sans-serif;font-weight:bolder;}#header{margin-bottom:0px;}</style></head><body><div id = "container"><div id="header"><h1>智慧教室</h1><p>Smart Classroom</p></div><div id="menu"><h2>Menu</h2><ul><li>HTML</li><li>CSS</li><li>JavaScript</li></ul></div><div id="content" ></div><div id="footer">Copyright W3School.com.cn</div></div></body></html>
2 回答

蝴蝶刀刀
TA貢獻1801條經驗 獲得超8個贊
1 2 3 4 5 6 7 8 | p{ line-height:20px; margin:0; text-indent:20px; color:#000; font-family:Arial, Helvetica, sans-serif; font-weight:bolder; } |
<p>標簽是帶有默認樣式的,這一點你必須要知道。
首先,你在<h1>標簽下方使用了該標簽,而后,你讓P標簽的line-height為零,這是不合理的,要知道,line-height表示你的這個標簽中文字垂直占位,這個數字要合理,比如你這里,你可以使用20px;
而p標簽還帶有margin-top和margin-bottom的默認樣式,你已經讓p標簽的margin-top為5px了,那么這個空隙,就是margin-bottom帶來的。
所以,要讓你的p標簽沒有那個所謂的空隙,就要加上margin-bottom:0;或者是在定義margin-top之前,定義margin:0;都可以。
P標簽樣式修改后為上面代碼框中的樣式。
- 2 回答
- 0 關注
- 308 瀏覽
添加回答
舉報
0/150
提交
取消