CSS浮動為什么不會遮蓋同級元素_html/css_WEB-ITnose
來源:懂視網
責編:小采
時間:2020-11-27 16:39:17
CSS浮動為什么不會遮蓋同級元素_html/css_WEB-ITnose
CSS浮動為什么不會遮蓋同級元素_html/css_WEB-ITnose:html+CSS源碼: img {border:solid 1px green;display:block;}#id1{float:left;}div{border:solid 2px blue;}p{border:solid 1px red;}This is some text. This is some text. This is some te
導讀CSS浮動為什么不會遮蓋同級元素_html/css_WEB-ITnose:html+CSS源碼: img {border:solid 1px green;display:block;}#id1{float:left;}div{border:solid 2px blue;}p{border:solid 1px red;}This is some text. This is some text. This is some te
html+CSS源碼:


This is some text. This is some text. This is some text.This is some text. This is some text. This is some text.
效果如下如:
問題:
W3CSchool中講解CSS定位,浮動那一節中,明確說對框1進行向左浮動時會遮住框2,原因是浮動后,元素脫離了文檔流,不占據空間。為什么我對兩張圖中的之一進行浮動時,不會遮住另一張圖呢???瀏覽器是IE8核心的360瀏覽器。
我的理解錯在了哪里?
回復討論(解決方案)
測試地址見W3CSchool,連接:http://www.w3school.com.cn/tiy/t.asp?f=csse_float
好好理解一下吧。再給你一個地址:
http://www.w3school.com.cn/css/css_positioning_floating.asp
會遮蓋的浮動不是float,而是position:absolute;這個屬性會使元素脫離文檔流,相當于懸浮在頁面上
試了一下,img就不行,但是你要是單單是div的話,就能出現你說的那個樣子,框1遮住框2
試了一下,img就不行,但是你要是單單是div的話,就能出現你說的那個樣子,框1遮住框2
并不是img和div的問題好么,你試驗的肯定不對(我估計你設置的是第一個DIV是浮動的,第二個不浮動)。
我差不多已經弄明白了,對于元素來說,這個是W3Cschool講的不夠明確,具體見我的blog:http://blog.csdn.net/k346k346/article/details/48530467
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
CSS浮動為什么不會遮蓋同級元素_html/css_WEB-ITnose
CSS浮動為什么不會遮蓋同級元素_html/css_WEB-ITnose:html+CSS源碼: img {border:solid 1px green;display:block;}#id1{float:left;}div{border:solid 2px blue;}p{border:solid 1px red;}This is some text. This is some text. This is some te