如何在iOS Safari上设置渐变背景透明度?

时间:2018-01-17 23:26:28

标签: ios css mobile-safari

以下CSS在Safari上不起作用(在iPad iOS上测试):

.map-left-navi {
    background: #ffffff;
    background: -moz-linear-gradient(left, #ffffff 35%, transparent 100%);
    background: -webkit-linear-gradient(left, #ffffff 35%,transparent 100%);
    background: linear-gradient(to right, #ffffff 35%,transparent 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='transparent',GradientType=1 );
}

关于保持透明度的解决方法的任何想法?

修改 - 解决方案:

使用rgba CSS颜色值:

.map-left-navi {
    background: #ffffff;
    background: -moz-linear-gradient(left, rgba(255,255,255, 0.35), rgba(255,255,255, 0));
    background: -webkit-linear-gradient(left, rgba(255,255,255, 0.35), rgba(255,255,255, 0));
    background: linear-gradient(to right, rgba(255,255,255, 0.35), rgba(255,255,255, 0));
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='transparent',GradientType=1 );
}

1 个答案:

答案 0 :(得分:3)

使用rgba而不是透明。

.map-left-navi {
    background: #ffffff;
    background: -moz-linear-gradient(left, rgba(255,255,255, 0.35), rgba(255,255,255, 0));
    background: -webkit-linear-gradient(left, rgba(255,255,255, 0.35), rgba(255,255,255, 0));
    background: linear-gradient(to right, rgba(255,255,255, 0.35), rgba(255,255,255, 0));
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='transparent',GradientType=1 );
}