【问题标题】:Responsive website works in remote in chrome but not when it's live响应式网站在 chrome 中远程工作,但不是在它上线时
【发布时间】:2022-01-18 20:11:09
【问题描述】:

当我在 127.0.0.1 上的 chrome 中“直播”时,网站库会响应所有尺寸。当我将它上传到实际的域和主机时,所有手机上的画廊都很大。下面是我的代码和 CSS。

* {
    box-sizing: border-box;
  }
  
  img {
    max-width: 100%;
    vertical-align: top;
  }
  
  #gallery {
      display: flex;
      margin: 10px auto;
      max-width: 100%;
      position: relative;
      padding-top: $max-img-height/$max-img-width * 100%;
    }
<section class="gallery">
  <div class="gallery__item">
    <input type="radio" id="img-1" checked name="gallery" class="selector">
    <img class="gallery__img" src="images/p1.jpg" alt=""/>
  </div>
  <div class="gallery__item">
    <input type="radio" id="img-2" name="gallery" class="selector"/>
    <img class="gallery__img" src="images/p2.jpg" alt=""/>
  </div>
</section>

【问题讨论】:

    标签: css responsive-design


    【解决方案1】:

    您是否在头部添加了视口的元数据?

    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no" /&gt;

    【讨论】:

    • 我确实有
    • 如果不查看上下文中的所有内容,很难判断,但可能您的主机没有编译 css....当您在浏览器中检查时,padding-top: $max-img-height/$max-img-width * 100%; 是否呈现为值?
    猜你喜欢
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-30
    • 2015-09-28
    • 1970-01-01
    • 2018-05-03
    相关资源
    最近更新 更多