DIV+CSS之float

來源:互聯網
上載者:User

test.html:

 

<html><br /><head><br /><link rel="stylesheet" type="text/css" media="screen" href="c.css" mce_href="c.css" /><br /></head><br /><body><br /><div id="footer2"><br />this is a footer2 div<br /></div><br /><p id="p1"><br />this is a p1 p<br /></p><br /><p id="p2"><br />this is a p2 p<br /></p><br /><div id="footer3"><br />this is a footer3 div<br /></div><br /></body><br /></html>

c.css:

div#footer2 {<br />float:left;<br /> background-color: #faf;<br /> width: 200px;<br />height:80px;<br />margin: 10px;<br />}<br />#p1{<br />float: right;<br />background-color: #afa;<br />width: 200px;<br />height:80px;<br />margin: 2px;<br />}<br />#p2{<br />float: right;<br />background-color: #afa;<br />width: 200px;<br />height:80px;<br />margin: 2px;<br />}<br />#footer3 {<br />float:right;<br />background:#afe;<br />width: 200px;<br />height:80px;<br />margin: 2px;<br />}

 

1.

中間有兩個<p>元素,那麼問題就來了,如果在css裡沒有設定margin則在FF中樣子會與想像中的不同,div 與

p 的高度會不相同。

加個margin就沒事了,即使傎是0。

 

2.css中float 與 clear 不能一起使用,一起用clear會不起作用。

所以現在還不曉得既讓footer2 clear both又讓它向右浮動該咋辦?

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.