在iPad上无法显示背景图片。
P粉879517403
P粉879517403 2023-07-25 11:58:00
[CSS3讨论组]
<p>我在导航栏下方放置了一张背景图片,当你向下滚动时,导航栏会与你一起向下移动。但是当我在iPad上查看时,发现背景图片呈现为接近黑色的深蓝色。</p> <pre class="brush:php;toolbar:false;">.background__image { width: 100%; background-image: url("https://background-image.jpg"); background-repeat: no-repeat; background-position: center center; background-attachment: fixed ; background-size: cover; height: 800px; text-align: center; display: flex; justify-content: center; }</pre> <p><br /></p>
P粉879517403
P粉879517403

全部回复(1)
P粉680087550
.background__image {
  width: 100%;
  background-image: url("https://background-image.jpg");
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
  background-size: cover;
  height: 800px;
  text-align: center;
  display: flex;
  justify-content: center;
}

@media (max-width: 768px) {
  /* Adjust the max-width value as needed */
  .background__image {
    background-attachment: scroll;
  }
}

尝试使用媒体查询设置最大宽度为768px(根据您的需求进行调整),以针对较小的屏幕,如iPad或其他移动设备。在媒体查询内部,将background-attachment属性设置为scroll,使背景图片能够随内容在这些设备上一起滚动。
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号