如何在微信小程序中开发出「上下浮动的箭头」

52 阅读1分钟

wxml

<view class="arrow-up"></view>
<view class="arrow-down"></view>

wxss

.arrow-up {
    width: 25rpx;
    height: 25rpx;
    border-top: 6rpx solid white;
    border-right: 6rpx solid white;
    margin-left: 50%;
    transform: translateX(-50%) rotate(-45deg);
    animation: arrow-up-animation 3s infinite;
    position: absolute;
}

@keyframes arrow-up-animation {
    0% {
        top: 11vh;
    }
    50% {
        top: 8vh;
    }
    100% {
        top: 11vh;
    }
}

.arrow-down {
    width: 25rpx;
    height: 25rpx;
    border-top: 6rpx solid white;
    border-right: 6rpx solid white;
    margin-left: 50%;
    transform: translateX(-50%) rotate(135deg);
    animation: arrow-down-animation 3s infinite;
    position: absolute;
}

@keyframes arrow-down-animation {
    0% {
        bottom: 8vh;
    }
    50% {
        bottom: 11vh;
    }
    100% {
        bottom: 8vh;
    }
}