gpt4 book ai didi

css - Firefox 不透明度(透明度)渐变 - 淡出图像

转载 作者:技术小花猫 更新时间:2023-10-29 11:24:02 26 4
gpt4 key购买 nike

我有一个包含内容的元素。

元素及其内容应该在左侧完全不透明,在右侧完全透明。从右到左均匀分级。

由于融合的内容和背景不固定,无法提前制作图像。

我知道渐变可以用作背景 (-moz-linear-gradient),但这对我没有帮助 - 在这里,我需要元素本身的内容淡出。

我已经能够在 IE(Alpha 蒙版)和 Webkit(图像蒙版)中执行此操作,但在 FF 中完全被难住了。

如果有办法,我不介意使用 SVG。

请帮忙?

最佳答案

本页解释了如何为 FF 3.5+ 实现这一点

https://developer.mozilla.org/en/applying_svg_effects_to_html_content

您可能希望在名为 mask.svg 的文件中包含这样的内容:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
version="1.1"
baseProfile="full">
<mask id="m1" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">
<linearGradient id="g" gradientUnits="objectBoundingBox" x2="1">
<stop stop-color="white" offset="0"/>
<stop stop-color="white" stop-opacity="0" offset="1"/>
</linearGradient>
<rect x="0" y="0" width="1" height="1" fill="url(#g)"/>
</mask>
</svg>

然后在您的 CSS 中包含以下内容:

mask: url(/path/to/mask.svg#m1);

关于css - Firefox 不透明度(透明度)渐变 - 淡出图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2630996/

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