css - 偽類(lèi)before/after中的圖片大小是不是不能設(shè)置的?
問(wèn)題描述
#center_box:before{content:url(http://localhost/quding/photos/u14.png);position: absolute;width:1000px;height:200px;z-index: 100;top: -110px; }
隨我怎么調(diào)width,height都沒(méi)變化.
問(wèn)題解答
回答1:你可以把圖片設(shè)為背景圖片,通過(guò)bakckground-size來(lái)設(shè)置大小
#center_box:before{ content:’’; background-image:url(http://localhost/quding/photos/u14.png); background-size:1000px 200px; position: absolute; width:1000px; height:200px; z-index: 100; top: -110px;}回答2:
:before /:after偽元素默認(rèn)是一個(gè)行內(nèi)元素,所以這個(gè)元素設(shè)置width/height是無(wú)效的就像你對(duì)a元素設(shè)置width/height一樣設(shè)置position: absolute;后這個(gè)元素的display屬性計(jì)算為block值;但是設(shè)置的width/height針對(duì)的是:before/:after生成的匿名替換元素,而不是其中的content所以圖片的大小是沒(méi)有效果的
相關(guān)文章:
1. button按鈕點(diǎn)擊了沒(méi)有任何反應(yīng)2. mysql - redis和mongodb怎么結(jié)合3. ddos - apache日志很多其它網(wǎng)址,什么情況?4. php安裝lpsolve 擴(kuò)展求助5. pbootcms程序的詳情頁(yè)模板想要實(shí)現(xiàn)多版塊展現(xiàn),說(shuō)不清楚,我截圖在里面6. JSP頁(yè)面導(dǎo)入問(wèn)題類(lèi)文件放在WEB-INF / classes中的包中7. html5和Flash對(duì)抗是什么情況?8. python - type函數(shù)問(wèn)題9. 第6行的$_GET[’F’]沒(méi)有定義???求問(wèn)一下是什么意思?10. index.php錯(cuò)誤,求指點(diǎn)
