why does CSS background-size: cover not work in portrait mode on iOS?

后端 未结 5 628
礼貌的吻别
礼貌的吻别 2020-12-28 09:16

I\'m trying to set up a manualy splash-image across devices. I\'m doing so by checking for orientation (touch devices) or screen width vs. sc

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-28 09:52

    Code here

    It fixing background images for ipad

    Just enter sizes according to your image dimentions

    /* Page background-image landscape for iPad 3 */
    @media only screen
      and (min-device-width: 768px)
      and (max-device-width: 1024px)
      and (orientation: landscape)
      and (-webkit-min-device-pixel-ratio: 2) {
      .introduction-section {
        -webkit-background-size: 2024px 768px !important;
        background-size: 2024px 768px !important;
        background: url('background-image.jpg') no-repeat center top #000 !important;
      }
    }
    /* Page background-image portrait for iPad 3 */
    @media only screen
      and (min-device-width: 768px)
      and (max-device-width: 1024px)
      and (orientation: portrait)
      and (-webkit-min-device-pixel-ratio: 2) {
      .introduction-section {
        -webkit-background-size: 2024px 768px !important;
        background-size: 2024px 768px !important;
        background: url('background-image.jpg') no-repeat center top #000 !important;
      }
    }
    /* Page background-image landscape for iPad 1/2 */
    @media only screen
      and (min-device-width: 768px)
      and (max-device-width: 1024px)
      and (orientation: landscape)
      and (-webkit-min-device-pixel-ratio: 1) {
      .introduction-section {
        background: url('background-image.jpg') no-repeat center top #000 !important;
        -webkit-background-size: 2024px 768px !important;
        background-size: 2024px 768px !important;
      }
    }
    /* Page background-image portrait for iPad 1/2 */
    @media only screen
      and (min-device-width: 768px)
      and (max-device-width: 1024px)
      and (orientation: portrait)
      and (-webkit-min-device-pixel-ratio: 1) {
      .introduction-section {
        background: url('background-image.jpg') no-repeat center top #000 !important;
        -webkit-background-size: 5024px 2024px !important;
        background-size: 5024px 2024px !important;
      }
    }
    

提交回复
热议问题