簡體   English   中英

媒體查詢適用於使用 DevTools 進行縮放,但在 iPhone 上查看時無效

[英]Media query works for scaling using DevTools, but not when viewed on iPhone

我正在使用 Google 的模型查看器 API,但在 iPhone 上查看時,我似乎無法將 slider 欄縮小。 我已經指定了媒體查詢,它在 DevTools 上按預期工作,但是當我在 iPhone 上查看該網站時,設計中斷了。 和 webkit 的外觀有關系嗎? 我試圖使用 * 選擇器禁用所有這些。

我試圖縮小的元素是:“滑塊”。

所有信息都在這里: https://codepen.io/kaijinny/pen/oNGWLvX

HTML:

      <div class='model_box'>
        <model-viewer bounds="tight" src="https://cdn.glitch.com/36cb8393-65c6-408d-a538-055ada20431b/Astronaut.glb?1542147958948" ios-src="https://cdn.glitch.com/36cb8393-65c6-408d-a538-055ada20431b/Astronaut.usdz?v=1569545377878" ar
          ar-modes="webxr scene-viewer quick-look" camera-controls environment-image="neutral"
          poster="https://cdn.glitch.com/36cb8393-65c6-408d-a538-055ada20431b%2Fposter-astronaut.png?v=1599079951717" shadow-intensity="1" auto-rotate">
          <div id="annotation">Open Conformation</div>
          <div class="progress-bar hide" slot="progress-bar">
            <div class="update-bar"></div>
          </div>
          <button slot="ar-button" id="ar-button">
            View in AR
          </button>

          <div class="slider">
            <div class="slides">
              <button class="slide selected" onclick="switchSrc(this, 's-1')"
                style="background-image: url('https://via.placeholder.com/150.png');">

              </button><button class="slide" onclick="switchSrc(this, 's-2')"
                style="background-image: url('https://via.placeholder.com/150.png');">

              </button><button class="slide" onclick="switchSrc(this, 's-3')"
                style="background-image: url('https://via.placeholder.com/150.png');">

              </button><button class="slide" onclick="switchSrc(this, 's-4')"
                style="background-image: url('https://via.placeholder.com/150.png');">

              </button><button class="slide" onclick="switchSrc(this, 's-5')"
                style="background-image: url('https://via.placeholder.com/150.png');">
              </button>
            </div>
          </div>
        </model-viewer>

CSS:

@media only screen 
  and (max-width: 460px) {
  .slider {
      transform: scale(70%)!important;
      overflow: visible;
  }
  .slides {
    overflow-x: visible;
  }
}

model-viewer >.progress-bar {
  background-color: #6C566F;
}
/* This keeps child nodes hidden while the element loads */
:not(:defined) > * {
  display: none;
}

.progress-bar {
  display: block;
  width: 33%;
  height: 10%;
  max-height: 2%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
  border-radius: 25px;
  box-shadow: 0px 3px 10px 3px rgba(0, 0, 0, 0.5), 0px 0px 5px 1px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.progress-bar.hide {
  visibility: hidden;
  transition: visibility 0.3s;
}

.update-bar {
  background-color: #e0e0e0;
  width: 0%;
  height: 100%;
  border-radius: 25px;
  float: left;
  transition: width 0.3s;
}

#ar-button {
  background-image: url(/assets/graphics/ar_icon.png);
  background-repeat: no-repeat;
  background-size: 20px 20px;
  background-position: 12px 50%;
  background-color: #fff;
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0px 16px 0px 40px;
  font-family: Roboto Regular, Helvetica Neue, sans-serif;
  font-size: 14px;
  color:#000000;
  height: 36px;
  line-height: 36px;
  border-radius: 18px;
  border: 1px solid #DADCE0;
}

#ar-button:active {
  background-color: #E8EAED;
}

#ar-button:focus {
  outline: none;
}

#ar-button:focus-visible {
  outline: 1px solid #CBC8FD;
}

@keyframes circle {
  from { transform: translateX(-50%) rotate(0deg) translateX(50px) rotate(0deg); }
  to   { transform: translateX(-50%) rotate(360deg) translateX(50px) rotate(-360deg); }
}

@keyframes elongate {
  from { transform: translateX(100px); }
  to   { transform: translateX(-100px); }
}

model-viewer > #ar-prompt {
  position: absolute;
  left: 50%;
  bottom: 60px;
  animation: elongate 2s infinite ease-in-out alternate;
  display: none;
}

model-viewer[ar-status="session-started"] > #ar-prompt {
  display: block;
}

model-viewer > #ar-prompt > img {
  animation: circle 4s linear infinite;
}

.model_box {
  margin: 3em auto;
  display: flex;
  flex-direction: column;
  max-width: 80%;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

model-viewer {
  width: 100%;
  height: 800px;
  background-color: #495057;
  --poster-color: #ffffff00;
  -webkit-appearance: none;
}

這可能是 ios safari 問題,因為比例不適用於 14.5 以上的舊版本。 您可以嘗試添加前綴:

-webkit-transform: scale(70%)!important;

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM