基本上,当我的盔甲被填满时,会有一些元素弹出,我需要一个转换来改变位置,因为它刚刚弹出很难看!唯一阻止我的是我对CSS一无所知,但这是我的代码
#armor {
position: relative;
width: 30px; height: 30px; left: 50%; margin-top: 15px; transform: translateX(-50%);
background-color: rgb(19, 19, 19);
border-style: solid; border-width: 12px; border-color: rgb(19, 19, 19); border-radius: 50%; display: flex;
box-shadow: 0px 0px 15px 0px rgba(103, 255, 194, 0.5);
animation-name: fadein;
animation-duration: 0.25s;
animation-timing-function: ease-in;
}
#armor .bar {
position: absolute;
width: 30px; height: 50%; bottom: 0;
background-image: url("img/armor.png"); background-position: bottom; background-size: cover; background-repeat: no-repeat; opacity: 1.0;
transition: height 0.25s;
}
#armor .bg {
position: absolute;
width: 30px; height: 30px; bottom: 0;
background-image: url("img/armor.png"); background-position: center; background-size: cover; background-repeat: no-repeat; opacity: 0.2;
}
JavaScript:
window.addEventListener("message", function (event) {
var oxygen = data.oxygen;
var oxygenStatus = data.oxygenStatus
document.getElementById('oxygen').getElementsByClassName('bar')[0].style.height = oxygen+"%"
switch(armorStatus) {
case true:
$("#armor").stop().fadeTo(400, 1)
break;
case false:
$("#armor").fadeOut()
break;
}
我也在使用 jQuery!
我已经尝试在 TOP 和 BOTTOM 上使用过渡,但它不起作用。谢谢你的帮助。
预览:第一:https ://prnt.sc/1gnqmfx 第二:https ://prnt.sc/1gnqsc3