CSS gradient not working on iOS

后端 未结 3 1947
梦毁少年i
梦毁少年i 2020-12-08 11:00

I have created a gradient background using a CSS generator. This works perfectly in all major browsers and on Android. However in iOS i get this.

What do I need to a

3条回答
  •  余生分开走
    2020-12-08 11:37

    Do give this a check in iOS but it ought to work:

    background: #ffad26; /* Old browsers */
    background: -moz-linear-gradient(top,  #ffad26 0%, #fea026 50%, #ff8b00 51%, #ff7701 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffad26), color-stop(50%,#fea026), color-stop(51%,#ff8b00), color-stop(100%,#ff7701)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  #ffad26 0%,#fea026 50%,#ff8b00 51%,#ff7701 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  #ffad26 0%,#fea026 50%,#ff8b00 51%,#ff7701 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  #ffad26 0%,#fea026 50%,#ff8b00 51%,#ff7701 100%); /* IE10+ */
    background: linear-gradient(to bottom,  #ffad26 0%,#fea026 50%,#ff8b00 51%,#ff7701 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffad26', endColorstr='#ff7701',GradientType=0 ); /* IE6-9 */
    

    I'd also recommend looking into a pre-processor like SASS which will generate a lot of these things for you.

    Alternative 1

    As an alternative, you could try using an inset box shadow. It's not exact, and it has it's limitations but it's just an option :)

    background-color:#FF8B00;
    -webkit-box-shadow: inset 0px 100px 0px 0px rgba(255, 255, 255, 0.5);
    box-shadow: inset 0px 100px 0px 0px rgba(255, 255, 255, 0.5);
    

    Alternative 2

    If you know the height, either use the box shadow above or just use a background image. That way you'll get cross-browser support without the mess that is a hundred prefixed CSS properties like above :)

提交回复
热议问题