gpt4 book ai didi

CSS:使用 Mask 作为 Webkit-Mask-Image 的后备

转载 作者:行者123 更新时间:2023-11-28 00:04:37 28 4
gpt4 key购买 nike

因此,我一直在尝试将背景图像裁剪成圆形 六边形,我发现 webkit 令人惊叹的 mask 图像非常容易地解决了我所有的问题。遗憾的是,它仅适用于 Chrome 和 Safari(当然)。

我如何为非 webkit 浏览器构建 SVG 掩码的回退?是否可以使用我的图像文件夹中的 .svg 文件作为蒙版,或者它是否必须在 html 文档的 svg 标签中定义?

这是我想要的 JSFiddle: http://jsfiddle.net/fbB3P/

CSS:

.hexagon {
position: relative;
display: inline-block;
width: 205px;
height: 233px;
overflow: hidden;
color: #fff;
-webkit-mask-image: url('http://i40.tinypic.com/kajqg.jpg');
text-align: center;
}

.hexagon .content {
height: 186px;
width: 186px;
margin: auto;
margin-top: 16px;
}

.hexagon a {
cursor: -webkit-zoom-in;
cursor: -moz-zoom-in;
}

HTML:

<div class="hexagon" style="background: url('https://s3.amazonaws.com/images.dailydabbles.com/artwork/skull-link5243b4c783a87-crop-260x260-medium.png');">
<a href="#skullkid">
<div class="content"></div>
</a>
</div>

最佳答案

太糟糕的掩蔽有awful support .

我创建了另一种屏蔽方式,利用了 :before:after 伪元素。

jsFiddle demo here - 更好的跨浏览器支持。

HTML

<div class="hex"></div>

CSS

.hex {
width: 205px;
height: 233px;
position: relative;
background: url('https://s3.amazonaws.com/images.dailydabbles.com/artwork/skull-link5243b4c783a87-crop-260x260-medium.png');
}

.hex:before {
content: "";
width: 0;
height: 0;
border-bottom: 60px solid transparent;
border-left: 103px solid white;
border-right: 102px solid white;
position: absolute;
}

.hex:after {
content: "";
width: 0;
position: absolute;
bottom: 0px;
border-top: 60px solid transparent;
border-left: 103px solid white;
border-right: 102px solid white;
}

关于CSS:使用 Mask 作为 Webkit-Mask-Image 的后备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19201882/

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