I am attempting to make the icon appear in the middle of the screen before it transitions off to the left. Here is my code at the moment:
#courseIcon {
position: relative;
background: url(https://placehold.it/100x100);
background-size: contain;
background-repeat: no-repeat;
background-position: center;
width: 100px;
height: 100px;
top: 0;
left: 20%;
margin-left: -125px;
}
/* ICON TRANSITION */
.moveIcon {
-webkit-animation: moveIcon 2s;
animation: moveIcon 2s;
animation-fill-mode: backwards;
animation-delay: 3s;
}
@-webkit-keyframes moveIcon {
from {
-webkit-transform: translateX(500px);
}
to {
-webkit-transform: translateX(0px);
}
}
@keyframes moveIcon {
from {
transform: translateX(500px);
}
to {
transform: translateX(0px);
}
}
<div id="courseIcon" class="moveIcon"></div>
At the moment I have just set translatex: 500px
as this is roughly half of the screen I am viewing it on. Is there a way of getting the transition to start in the centre of the page, regardless of the screensize? Here is my code in a fiddle.
Thank you for your time.