想實(shí)現(xiàn)css的切圖功能,代碼在瀏覽器上有效,小程序切圖無效,甚至連圖片都沒有了。
test.png是一張320x347像素的圖片。
wxml代碼如下:
<image src="/images/test.png" style="position:absolute;clip:rect(0px 100px 100px 0px);width:320px;height:347px">
</image>
將style寫在wxss,同無效。
<image class="the-paper" src="/images/paper.png">
</image>
.the-paper{
position:absolute;
clip:rect(0px 100px 100px 0px);width:320px;height:347px
}
哪位同學(xué)有解決方案?
網(wǎng)友回復(fù):
建議你用背景圖片,然后CSS定位過去,因?yàn)樾〕绦蚶锩娴膇mage標(biāo)簽和HTML中的還是有區(qū)別的~
徽信:mianhuabingbei
解決方案:
.the-paper{
background-image:url('外網(wǎng)url');
background-repeat:no-repeat;
background-position:-100px -100px;
height:347px;
width:320px;
}