Alternatives to background-attachment: fixed

后端 未结 2 881
眼角桃花
眼角桃花 2021-01-21 08:20

Since background-attachment:fixed doesn\'t work on some mobile browsers (e.g. on iOS), what alternatives are there, specifically when trying to implement the following demo: htt

2条回答
  •  情话喂你
    2021-01-21 09:13

        .bg 
        {
          background-image: url(bg.jpg);
          background-position: center;
          background-repeat: no-repeat;
          background-size: cover;
          position: fixed;
          top: 0px;
          bottom: 0px;
          left: 0px;
          right: 0px;
          z-index: -1;
          -webkit-transform: translateZ(0);
          pointer-events: none;
        }
    

    See this example: https://rawgit.com/arnaudbreton/background-fixed-chrome-rendering-issue/master/index-without-rendering-issue.html

    Taken from: http://blog.mention.com/building-a-beautiful-homepage-how-we-nailed-down-chrome-performance-rendering-issues/

提交回复
热议问题