简体   繁体   English

媒体查询适用于使用 DevTools 进行缩放,但在 iPhone 上查看时无效

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

I am using Google's modelviewer API, but I can't seem to get the slider bar to size down when viewed on iPhone.我正在使用 Google 的模型查看器 API,但在 iPhone 上查看时,我似乎无法将 slider 栏缩小。 I've specified the media query and it works as expected on DevTools, but when I view the site on my iPhone the design breaks.我已经指定了媒体查询,它在 DevTools 上按预期工作,但是当我在 iPhone 上查看该网站时,设计中断了。 Is it something to do with webkit appearance?和 webkit 的外观有关系吗? I have tried to disable all of them using the * selector.我试图使用 * 选择器禁用所有这些。

The element I am attempting to scale down is: "slider".我试图缩小的元素是:“滑块”。

All info here: https://codepen.io/kaijinny/pen/oNGWLvX所有信息都在这里: https://codepen.io/kaijinny/pen/oNGWLvX

HTML: 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: 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;
}

That's probably an ios safari issue as scale does not work for older versions than 14.5.这可能是 ios safari 问题,因为比例不适用于 14.5 以上的旧版本。 You could try adding the prefix:您可以尝试添加前缀:

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

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM