【发布时间】:2012-10-08 10:23:13
【问题描述】:
可能重复:
Is it possible to graduate the opacity of an HTML element?
我正在尝试使用 css 让 div(及其边框和内容)淡入透明(即顶部为实心,底部为透明)。
有没有办法做到这一点?
我已经能够通过以下方式淡出背景:
.fade-to-nothing
{
background-image: -moz-linear-gradient(top, rgba(255,255,255,1), rgba(255,255,255,0));
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(255,255,255,1)), to(rgba(255,255,255,0)));
background-image: -webkit-linear-gradient(top, rgba(255,255,255,1), rgba(255,255,255,0));
background-image: -o-linear-gradient(top, rgba(255,255,255,1), rgba(255,255,255,0));
background-image: linear-gradient(to bottom, rgba(255,255,255,1),rgba(255,255,255,0));
background-repeat: repeat-x;
}
但还没有找到一种方法来处理 div 的内容/边框。也许有某种嵌套或覆盖?
编辑 这就是我想要做的事情:
【问题讨论】:
-
容器上有单色背景吗?相关:stackoverflow.com/questions/12664132/…
-
是的,背景对于 div 和它下面的内容都是纯色
-
您能否发布一张您所拥有的屏幕截图以及您想要实现的目标的图片?我发现你的公式很难弄清楚。
标签: css transparency