如何在 div 边框上创建没有颜色的不透明度渐变?

发布于 2024-12-13 10:57:52 字数 668 浏览 5 评论 0原文

我有一个小问题,我不确定是否有解决方案。

基本上我想在 div 边框上创建不依赖于颜色的不透明度渐变。

让我解释一下。

我有一个“overflow:hidden”div(我们将其称为MainDiv),其中包含另一个大div(将称为SlideDiv),我使用jquery 在视口上滑动。主 div 有一个“全视口”背景复杂图像,也会移动。所有这些都创造了非常好的视差效果。

正如预期的那样,“SlideDiv”内容消失在视口边界之外。现在这就是窍门。我希望内容不仅消失,而且逐渐消失:)

为此,我需要在视口边框上设计不透明度渐变。由于背景上有一个必须始终可见的复杂图像,因此该渐变不能与颜色相关。换句话说,我想要一个“不透明度:1(我们看到内容)到不透明度:0(我们看不到内容)”渐变,而不是“不透明度:0(我们看到内容)到白色/黑色/绿色/任何颜色不透明度:1(内容位于不透明颜色后面)”渐变。

这意味着我不能使用 -webkit-gradient 或 -moz-linear-gradient。或者我可以吗?

由于业务相关原因,恐怕我无法向您展示任何内容。

问题是: - 是否可以使用 CSS2 或 3、jQuery 或插件或任何其他技术(不包括 flash)? - 如果是这样,怎么办? :)

我希望我说得清楚,但我不太确定,抱歉,大家好;)

问候, 吉布

I have a slight issue which I'm not sure has a solution.

Basically I want to create an opacity gradient on a div borders non dependant on a color.

Let me explain.

I have an "overflow:hidden" div (which we'll call MainDiv) that contain another big div (which will call SlideDiv) that I slide across the viewport using jquery. The main div has a "full viewport" background complex image that moves as well. The all thing create a really nice parallax effect.

As expected the "SlideDiv" content disappears beyond the viewport border. Now here is the trick. I'd like the content to not just disappear but to fade away :)

For this to work, I need to engineer an opacity gradient on the viewport borders. And as there is a complex image on the background that must be visible at all time, this gradient cannot be color related. In other terms, I'd like a "opacity:1 (we see the content) to opacity:0 (we don't see the content)" gradient and not a "opacity:0 (we see the content) to White/Black/Green/AnyColor opacity:1 (the content is behind a opaque color)" gradient.

That means that I can't use -webkit-gradient or -moz-linear-gradient. Or can I ?

I'm afraid I can't show you any thing for business related reasons.

Questions are :
- Is it possible using CSS2 or 3, jQuery or a plugin or any other technology (excluding flash) ?
- And if so, how ? :)

I hope I'm clear, but I'm not so sure so sorry guys ;)

Regards,
Jibou

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轻拂→两袖风尘 2024-12-20 10:57:52

酷..我从你的整个查询中得到的是
i.) 你想对边框应用渐变
ii.) 您还希望边框具有淡入和淡出效果。

如果我得到的结果正确或非常接近,你可以使用以下技巧。
i.) 访问此链接以使用 css 获取边框上的渐变。
ii.) 这可能很棘手:您可以创建一个带有渐变的 svg 形状,并将其绝对定位到具有完整宽度和高度的主 div 中(还有很多其他方法可以管理元素的高度和宽度) .)。由于它将是 SVG 图像或脚本,因此您无需担心结果。

如果我没有解决你的问题。让我知道我会再试一次。

Cool.. What I am getting from whole your query is
i.) you want to apply a gradient to the border
ii.) Also you want fade-in and fade-away effect to border.

if I got it correctly or very much near by it, you can use the following tricks.
i.) Visit this link to get the gradient on the border with css.
ii.) This may be tricky : You can create an svg shape for with gradients and place it with absolute positioning in to your main div with full width and height(there are a lot of other ways you can manage height and width of an element.). Since it will be an SVG image or script you don't need to worry about resultion.

if I am not reaching to the solution of your problem. let me know I will try again.

黯然 2024-12-20 10:57:52

看看这个。您可以选择您喜欢的渐变,并可以从中保存任何支持渐变的浏览器的 CSS

Take a look at this. You can choose the gradient you like and from it you can save the CSS for any browser that support gradients

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文