我想知道,這是可能的。我試圖用svg和clipPath來實現它。 (jsfiddle example)圖像的切出透明三角形
body { background-color: #e0e0e0;margin: 0px;width: 100%;height: 100%; }
#img-1 { clip-path: url(#clip-shape); }
<div id="image-wrapper" style="overflow: hidden; width: 100%; height: 150px;">
<div style="width: 100%; height: 100%;">
<svg id="image-svg" viewBox="0 0 100 100" height="100%" width="100%" preserveAspectRatio="xMinYMin slice">
<image id="img-1" class="svg-image" width="100%" height="100%" xlink:href="http://25.media.tumblr.com/tumblr_m5nre6cxkQ1qbs7p5o1_r1_500.jpg"></image>
<svg id="svg-defs" viewBox="0 0 100 100" height="100%" width="100%">
<defs>
<clipPath id="clip-shape">
<polygon points="0 0, 40 0, 50 10, 60 0, 100 0, 100 500, 0 500"></polygon>
</clipPath>
</defs>
</svg>
</div>
</div>
但它仍然不是我想要的,我敢肯定有更優雅和簡單的解決方案。圖像應該有一個底部對齊。切出部分的大小應爲像素且透明,以便下方的內容可見。請參閱下面的附圖。
我覺得你最好的辦法是用photoshop等paint.NET和您的圖像保存爲.png文件。然後將你的圖像作爲背景圖像應用於你的div。 –