我有一个div
带有背景图片。但是图像太亮了,以至于表单元素看起来不错(页面底部和顶部的白色元素),我添加了一个渐变叠加层,应该darken
从底部和顶部{在中心透明。
这是我的代码:
.landing-carousel .carousel-item::before {
background: rgb(111,111,111); /* Old browsers */
background: -moz-linear-gradient(top, rgba(111,111,111,0.1) 0%, rgba(255,255,255,0) 20%, rgba(255,255,255,0) 80%, rgba(111,111,111,0.1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(111,111,111,0.1) 0%,rgba(255,255,255,0) 20%,rgba(255,255,255,0) 80%,rgba(111,111,111,0.1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(111,111,111,0.1) 0%,rgba(255,255,255,0) 20%,rgba(255,255,255,0) 80%,rgba(111,111,111,0.1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6f6f6f', endColorstr='#6f6f6f',GradientType=0 ); /* IE6-9 */
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
这是三星Galaxy A9的结果(在Windows上也是如此)。但是在三星Galaxy S6 / S7 / S10上一切正常。
注意到条纹了吗?为什么渐变不平滑?
答案 0 :(得分:0)
尝试先放置前缀行。如果某些浏览器支持这两种浏览器,则它们可能会使用错误的实现。你可以试试看。
background: -moz-linear-gradient(top, rgba(111,111,111,0.1) 0%, rgba(255,255,255,0) 20%, rgba(255,255,255,0) 80%, rgba(111,111,111,0.1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(111,111,111,0.1) 0%,rgba(255,255,255,0) 20%,rgba(255,255,255,0) 80%,rgba(111,111,111,0.1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(111,111,111,0.1) 0%,rgba(255,255,255,0) 20%,rgba(255,255,255,0) 80%,rgba(111,111,111,0.1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
background: rgb(111,111,111); /* Old browsers */ //Put this at the end, but i'd just delete this line.
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6f6f6f', endColorstr='#6f6f6f',GradientType=0 ); /* IE6-9 */
但是Caniuse指出,现在您可以删除大多数前缀,因为Chrome和Firefox支持就可以了。因此,请尝试将其删除,也可以尝试此操作
background: linear-gradient(to bottom, rgba(111,111,111,0.1) 0%,rgba(255,255,255,0) 20%,rgba(255,255,255,0) 80%,rgba(111,111,111,0.1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
background: rgb(111,111,111); /* Old browsers */ //Put this at the end, but i'd just delete this line.
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6f6f6f', endColorstr='#6f6f6f',GradientType=0 ); /* IE6-9 */
让我知道它是否有效!