So I have an issues on mobile view for this accordion I made.
Once you have clicked through the menu and to the main content when you select between the different elements there is slight jump before the animation runs.
I can't figure out why it would be doing this or if it could be something to do with the animation timings I have used, so any suggestions would be welcome.
The easiest way to see what I have done is on the CodePen link below.
CodePen Link: https://codepen.io/nickelse/full/dypEyMK
Video of Issue: https://www.loom.com/share/cd1280d898d64b58abbfc1d7ce1fc824
html {
box-sizing: border-box;
font-size: 62.5%;
-webkit-overflow-scrolling: touch;
}
*, *:before, *:after { box-sizing: inherit; }
body {
background: #222;
font-family: 'Open Sans', sans-serif;
margin: 0;
padding: 0;
}
img {
height: auto;
max-width: 100%;
width: 100%;
}
.hozacc__wrapper {
display: flex;
overflow: hidden;
}
.hozacc__box {
align-items: center;
box-shadow: 0 5px 10px black;
cursor: pointer;
display: flex;
position: relative;
transition: all .5s;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
transform-origin: center;
width: 25%;
}
.hozacc__content--wrapper {
color: white;
display: none;
font-weight: 300;
margin: 0 auto;
text-align: center;
width: 100%;
}
.hozacc__content--container {
align-items: center;
display: flex;
}
.hozacc__box--one {
background: url('https://images.pexels.com/photos/3421920/pexels-photo-3421920.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260') no-repeat;
background-position: cover;
}
.hozacc__box--one.hozacc__active,
.hozacc__box--one.hozacc__inactive {
background: #0075BF;
}
.hozacc__box--two {
background: url('https://images.pexels.com/photos/940035/pexels-photo-940035.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260') no-repeat;
background-position: cover;
}
.hozacc__box--two.hozacc__active,
.hozacc__box--two.hozacc__inactive {
background: #469535;
}
.hozacc__box--three {
background: url('https://images.pexels.com/photos/3421920/pexels-photo-3421920.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260') no-repeat;
background-position: cover;
}
.hozacc__box--three.hozacc__active,
.hozacc__box--three.hozacc__inactive {
background: #CE7C36;
}
.hozacc__box--four {
background: url('https://images.pexels.com/photos/940035/pexels-photo-940035.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260') no-repeat;
background-position: cover;
}
.hozacc__box--four.hozacc__active,
.hozacc__box--four.hozacc__inactive {
background: #CE4E4E;
}
.hozacc__box--five {
background: url('https://images.pexels.com/photos/3421920/pexels-photo-3421920.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260') no-repeat;
background-position: cover;
}
.hozacc__box--five.hozacc__active,
.hozacc__box--five.hozacc__inactive {
background: #007A7C;
}
.hozacc__content--title {
background: rgba(0,0,0,.6);
border: 4px solid white;
color: white;
left: 50%;
padding-left: 20px;
padding-right: 20px;
position: absolute;
text-align: center;
top: 50%;
transition: all .2s;
}
.hozacc__inactive .hozacc__content--title {
background: none;
border: none;
transform: translate(-50%,-50%) rotate(-90deg);
}
.hozacc__content--title h1 {
font-weight: 700;
}
.hozacc__active {
width: 100%;
}
.hozacc__active .hozacc__content--title {
display: none;
}
.hozacc__fadein {
animation: hozaccFadeIn ease .9s;
display: block;
}
@keyframes hozaccFadeIn {
0% {
opacity: 0;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@media only screen and (max-width: 779px) {
.hozacc__flexy {
flex-wrap: wrap;
}
.hozacc__wrapper {
height: 500px;
}
.hozacc__box {
flex-basis: 50%;
max-width: 50%;
}
.hozacc__content--wrapper {
font-size: 14px;
}
.hozacc__content--container {
flex-wrap: wrap;
}
.hozacc__content--copy {
flex-basis: 100%;
max-width: 100%;
order: 2;
padding-left: 20px;
padding-right: 20px;
}
.hozacc__content--copy h2 {
font-size: 18px;
}
.hozacc__content--img {
flex-basis: 100%;
max-width: 100%;
order: 1;
padding-left: 20px;
padding-right: 20px;
}
.hozacc__content--img img {
border: 2px solid white;
box-sizing: border-box;
padding: 10px;
}
.hozacc__content--title {
/* transform: translate(-50%,-50%) rotate(-90deg); */
transform: translate(-50%,-50%);
}
.hozacc__inactive .hozacc__content--title {
white-space: nowrap;
}
.hozacc__content--title h1 {
font-size: 16px;
}
.hozacc__inactive {
flex-basis: 100px;
max-width: 100px;
}
.hozacc__active {
flex-basis: 100%;
max-width: 100%;
}
}
@media only screen and (min-width: 780px) {
.hozacc__wrapper {
height: 600px;
}
.hozacc__content--wrapper {
font-size: 18px;
}
.hozacc__content--copy {
flex-basis: 40%;
max-width: 40%;
padding-left: 40px;
padding-right: 40px;
}
.hozacc__content--img {
flex-basis: 60%;
max-width: 60%;
}
.hozacc__content--title {
transform: translate(-50%,-50%);
white-space: nowrap;
}
/* .hozacc__inactive .hozacc__content--title {
transform: translate(-50%,-50%) rotate(-90deg);
} */
.hozacc__content--title h1 {
font-size: 20px;
}
.hozacc__inactive {
width: 70px;
}
}
question from:
https://stackoverflow.com/questions/65899261/css-animation-jump-issue-on-mobile 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…