gpt4 book ai didi

html - Internet Explorer 和剪辑路径

转载 作者:技术小花猫 更新时间:2023-10-29 12:36:57 25 4
gpt4 key购买 nike

据我所知,clip-path 应该可以在 IE 中使用,正如许多文章和本教程中所演示的那样 CSS Masking

但是我无法让下面的程序在 IE 上正常运行,但它在 Chrome 上运行良好。

.container {
position: relative;
width: 240px;
height: 500px;
left: 50%;
top: 50%;
}

.pentagon {
-webkit-clip-path: polygon(0px 0px, 100px 0px, 112px 13px, 240px 13px, 240px 250px, -250px 250px);
-o-clip-path: polygon(0px 0px, 100px 0px, 112px 13px, 240px 13px, 240px 250px, -250px 250px);
-ms-clip-path: polygon(0px 0px, 100px 0px, 112px 13px, 240px 13px, 240px 250px, -250px 250px);
float: left;
}

.avatar {
margin-top: 50px;
}

html {
text-align: center;
min-height: 100%;
background: linear-gradient(white, #ddd);
}

h1,
p {
color: rgba(0, 0, 0, .3);
}
<div class="container">
<div class="avatar">
<img class="pentagon" src="http://25.media.tumblr.com/tumblr_m5nre6cxkQ1qbs7p5o1_r1_500.jpg" alt="" />
</div>
</div>

<svg>
<defs>
<clipPath id="pentagon" clipPathUnits="objectBoundingBox">
<polygon points=".5,0 1,.30 .2,1 .2,1 0,.30" />
</clipPath>
</defs>
</svg>

最佳答案

经过更深入的研究,当直接处理图像时,IE 仅支持矩形形状的剪辑,而不支持 clipPath 复杂形状。

我的解决方案是将图像添加到 SVG,如下所示,这次它在 Chrome 和 IE9+ 中都有效。

Demo JsFiddle

body {
background-color: #e0e0e0;
}

#image-wrapper {
position: relative;
}

.svg-background,
.svg-image {
clip-path: url(#clip-triangle);
}

.svg-image {
-webkit-transition: all 0.5s ease 0.2s;
-moz-transition: all 0.5s ease 0.2s;
opacity: 1;
transition: all 0.5s ease 0.2s;
}

svg.clip-svg {
height: 250px;
position: absolute;
width: 250px;
}

#svg-1 {
left: 0px;
top: 0px;
}
<div id="image-wrapper">
<svg id="svg-1" class="clip-svg">
<rect class='svg-background' width="300" height="300" fill="#ffffff" />
<image id="img-1" class='svg-image' width="300" height="300" xlink:href="http://25.media.tumblr.com/tumblr_m5nre6cxkQ1qbs7p5o1_r1_500.jpg" />
</svg>
</div>
<svg id="svg-defs">
<defs>
<clipPath id="clip-triangle">
<polygon points="0 0, 100 0, 112 13, 240 13, 240 250, -250 250"/>
</clipPath>
</defs>
</svg>

关于html - Internet Explorer 和剪辑路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21904672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com