我想创建一个使用内部和外部SVG的三角形。内部和外部SVG的剪辑路径
但是由于某些原因,它不起作用。
我试图用这个工具在这里:http://cssplant.com/clip-path-generator
,并得到它的“点”的坐标上创建我的内部和外部的SVG,但没有运气完美剪辑三角形。
这里是我的HTML:
<figure class="clip-holder">
<img src="https://www.thesun.co.uk/wp-content/uploads/2016/06/nintchdbpict000244881006.jpg" class="clip-svg-inline" width="200" height="200">
<figcaption>Inline SVG</figcaption>
</figure>
<figure class="clip-holder">
<img src="https://www.thesun.co.uk/wp-content/uploads/2016/06/nintchdbpict000244881006.jpg" width="200" height="200">
<figcaption>External SVG</figcaption>
</figure>
</div>
<svg class="clip-svg">
<defs>
<clipPath id="triangle" clipPathUnits="objectBoundingBox" >
<polygon points="120 263,325 262,222 42"/>
</clipPath>
</defs>
</svg>
而这里的CSS:
.clip-holder {
display: inline-block;
padding: 0;
margin: 30px;
}
.clip-css {
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.clip-svg {
width: 0;
height: 0;
margin: 0 auto;
}
.clip-svg-inline {
-webkit-clip-path: url("#triangle");
clip-path: url("#triangle");
}
.clip-svg-external {
-webkit-clip-path: url("https://www.thesun.co.uk/wp-content/uploads/2016/06/nintchdbpict000244881006.jpgt");
clip-path: url("https://www.thesun.co.uk/wp-content/uploads/2016/06/nintchdbpict000244881006.jpg");
}
我在犯错误?
这里的的jsfiddle:https://jsfiddle.net/stjtudvj/
(让我更好地了解的jsfiddle溶液)
剪辑路径必须指向clipPath元素,指向一个JPEG文件无效。在CSS文件中也没有三角形元素,它在html文件中,所以本地#triangle引用不会找到它。 –
有没有办法解决这个问题?内部和外部SVG的任何分辨率?我真的坚持罗伯特。 –
将剪辑路径指向clipPath元素。 –