I am using Google's modelviewer API, but I can't seem to get the slider bar to size down when viewed on iPhone. 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. Is it something to do with webkit appearance? 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
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.