position中的困惑,幫忙解決一下_html/css
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 16:39:39
position中的困惑,幫忙解決一下_html/css
position中的困惑,幫忙解決一下_html/css_WEB-ITnose: Document *{ margin:0; padding:0; } .parent{ background: red; position: absolute; left:60px; width: 300px; height: 300px; } .childRight{ background: blue; width: 240px; position: relative; right:60px; } .child-Right{ background: yellow; w
導(dǎo)讀position中的困惑,幫忙解決一下_html/css_WEB-ITnose: Document *{ margin:0; padding:0; } .parent{ background: red; position: absolute; left:60px; width: 300px; height: 300px; } .childRight{ background: blue; width: 240px; position: relative; right:60px; } .child-Right{ background: yellow; w

Document parent childRight child-Right childLeft child-Left hello
大家?guī)兔匆幌?,父?biāo)簽設(shè)置絕對(duì)定位,子標(biāo)簽都設(shè)置了相對(duì)定位,兩個(gè)問(wèn)題:1.為什么right:60px和left:-60px相同,第三個(gè)子標(biāo)簽(.childLeft)為什么不顯示顏色了?
回復(fù)討論(解決方案)
對(duì),
相對(duì)定位情況下,是以元素自身原本的位置進(jìn)行偏移,右邊偏移正60px就等于左邊偏移負(fù)60px。
為什么不顯示顏色
childLeft
這么明顯,等于號(hào)你打成減號(hào)了
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
position中的困惑,幫忙解決一下_html/css
position中的困惑,幫忙解決一下_html/css_WEB-ITnose: Document *{ margin:0; padding:0; } .parent{ background: red; position: absolute; left:60px; width: 300px; height: 300px; } .childRight{ background: blue; width: 240px; position: relative; right:60px; } .child-Right{ background: yellow; w