我这里有点问题。:) 我尝试用 css3 制作一个很好的气球动画。Link我的问题是我希望黑线贴在地面上,然后稍微移动带有黑线的气球。就像风在左右吹气球:)
.container {
width: 640px;
height: 480px;
position: absolute;
left: 25%;
top: 25%;
background: url('mario_time.jpg') no-repeat;
background-size: cover;
cursor: crosshair;
position: absolute;
}
.balloon {
display: inline-block;
position: relative;
top: 200px;
left: 80px;
-webkit-animation:inflatable 6s ease-in-out infinite;
-moz-animation:inflatable 6s ease-in-out infinite;
-o-animation:inflatable 6s ease-in-out infinite;
animation:inflatable 6s ease-in-out infinite;
}
.percentage {
margin-top: 20px;
font-family: robot;
font-size: 20px;
color: black;
padding: 7px 25px;
padding-top: 6px;
border-radius: 25px;
margin: auto;
width: 50px;
}
.score-box {
font-family: 'Orbitron', sans-serif;
font-size: 40px;
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
}
.score-box .label,
.score-box .percentage{
visibility: hidden;
}
.welcome-box .ready {
font-family: 'Orbitron', sans-serif;
font-size: 40px;
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
visibility: visible;
}
.score-box.ready {
top: 20%;
}
.welcome-box.ready {
top: 20%;
}
.score-box.ready .label,
.score-box.ready .percentage {
visibility: visible;
}
.welcome-box.ready .badge {
text-align: center;
width: 250px;
height: 100px;
padding: 15px;
margin: 0px auto;
border-radius: 15px;
border: 4px solid #fff;
background-color: white;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.62);
color: black;
visibility: visible
}
.score-box.ready.ready .badge {
width: 250px;
height: 100px;
padding: 15px;
margin: 0px auto;
border-radius: 15px;
border: 4px solid #fff;
background-color: white;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.62);
color: black
}
.label {
font-family: roboto;
font-size: 18px;
}
.balloon {
width: 38px;
margin: 0 auto;
padding-top: 30px;
position: relative;
top:22%;
}
.balloon > div {
width:100px;
height:130px;
border-radius:0;
border-radius:80% 80% 80% 80%;
margin: 0 auto;
position: absolute;
padding:10px;
-webkit-transform-origin: bottom center;
}
.balloon > div{
background: rgb(30,144,255);;
left: 0;
-webkit-animation:balloon1 6s ease-in-out infinite;
-moz-animation:balloon1 6s ease-in-out infinite;
-o-animation:balloon1 6s ease-in-out infinite;
animation:balloon1 6s ease-in-out infinite;
&:before {
color: rgba(182, 15, 97, 0.9); ;
}
}
.balloon > div:before {
color:rgb(30,144,255);
position:absolute;
bottom:-11px;
left: 52px;
content:"▲";
font-size:1em;
}
.balloon > :after {
display:inline-block;
top:153px;
top:167px;
position:absolute;
height:180px;
width:3px;
margin:0 auto;
content:"";
background:rgba(0,0,0,0.2);
left: 60px;
pointer-events: none
}
/*BALLOON 1 4*/
@-webkit-keyframes balloon1 {
0%,100%{ -webkit-transform:translateY(0) rotate(-6deg);}
50%{ -webkit-transform:translateY(0px) rotate(8deg); }
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Baloon_shooter</title>
<link rel="stylesheet" href="main.css" type="text/css" charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'>
</head>
<body>
<div class ="container">
<div class="balloon" style="left:50px">
<div class="balloon1"></div>
</div>
<div class="balloon" style="left:150px">
<div class="balloon2"></div>
</div>
<div class="balloon" style="left:250px">
<div class="balloon3"></div>
</div>
<div class="balloon" style="left:350px">
<div class="balloon4"></div>
</div>
<div class="score-box">
<div class="badge">
<span class="label">Gratulálunk, az ön nyereménye:</span>
<div class="percentage">0</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js">
</script>
<script src="script.js"> </script>
</body>
</html>
.container {
width: 640px;
height: 480px;
position: absolute;
left: 25%;
top: 25%;
background: url('mario_time.jpg') no-repeat;
background-size: cover;
cursor: crosshair;
position: absolute;
}
.balloon {
display: inline-block;
position: relative;
top: 200px;
left: 80px;
-webkit-animation:inflatable 6s ease-in-out infinite;
-moz-animation:inflatable 6s ease-in-out infinite;
-o-animation:inflatable 6s ease-in-out infinite;
animation:inflatable 6s ease-in-out infinite;
}
.percentage {
margin-top: 20px;
font-family: robot;
font-size: 20px;
color: black;
padding: 7px 25px;
padding-top: 6px;
border-radius: 25px;
margin: auto;
width: 50px;
}
.score-box {
font-family: 'Orbitron', sans-serif;
font-size: 40px;
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
}
.score-box .label,
.score-box .percentage{
visibility: hidden;
}
.welcome-box .ready {
font-family: 'Orbitron', sans-serif;
font-size: 40px;
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
visibility: visible;
}
.score-box.ready {
top: 20%;
}
.welcome-box.ready {
top: 20%;
}
.score-box.ready .label,
.score-box.ready .percentage {
visibility: visible;
}
.welcome-box.ready .badge {
text-align: center;
width: 250px;
height: 100px;
padding: 15px;
margin: 0px auto;
border-radius: 15px;
border: 4px solid #fff;
background-color: white;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.62);
color: black;
visibility: visible
}
.score-box.ready.ready .badge {
width: 250px;
height: 100px;
padding: 15px;
margin: 0px auto;
border-radius: 15px;
border: 4px solid #fff;
background-color: white;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.62);
color: black
}
.label {
font-family: roboto;
font-size: 18px;
}
.balloon {
width: 38px;
margin: 0 auto;
padding-top: 30px;
position: relative;
top:22%;
}
.balloon > div {
width:100px;
height:130px;
border-radius:0;
border-radius:80% 80% 80% 80%;
margin: 0 auto;
position: absolute;
padding:10px;
-webkit-transform-origin: bottom center;
}
.balloon > div{
background: rgb(30,144,255);;
left: 0;
&:before {
color: rgba(182, 15, 97, 0.9); ;
}
}
.balloon > div:before {
color:rgb(30,144,255);
position:absolute;
bottom:-11px;
left: 52px;
content:"▲";
font-size:1em;
}
.balloon > :after {
display:inline-block;
top:153px;
top:167px;
position:absolute;
height:180px;
width:3px;
margin:0 auto;
content:"";
background:rgba(0,0,0,0.2);
left: 60px;
pointer-events: none;
-webkit-animation:balloon1 6s ease-in-out infinite;
-moz-animation:balloon1 6s ease-in-out infinite;
-o-animation:balloon1 6s ease-in-out infinite;
animation:balloon1 6s ease-in-out infinite;
-webkit-transform-origin: bottom;
}
/*BALLOON 1 4*/
@-webkit-keyframes balloon1 {
0%,100%{ -webkit-transform:translateY(0) rotate(-6deg);}
50%{ -webkit-transform:translateY(0px) rotate(8deg); }
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Baloon_shooter</title>
<link rel="stylesheet" href="main.css" type="text/css" charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'>
</head>
<body>
<div class ="container">
<div class="balloon" style="left:50px">
<div class="balloon1"></div>
</div>
<div class="balloon" style="left:150px">
<div class="balloon2"></div>
</div>
<div class="balloon" style="left:250px">
<div class="balloon3"></div>
</div>
<div class="balloon" style="left:350px">
<div class="balloon4"></div>
</div>
<div class="score-box">
<div class="badge">
<span class="label">Gratulálunk, az ön nyereménye:</span>
<div class="percentage">0</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js">
</script>
<script src="script.js"> </script>
</body>
</html>
如果我像上面这样使用我的 css,我可以正确移动黑线,但我不能像我想要的那样移动气球:/。
也许这就是你想要的?
不完全是您想要的,但有点相似(没有图形),
可能您必须根据需要对其进行调整:)
:root {
--swings: calc(60 / 10 * 2s);
--swing-time: var(--swings);
}
.balloon {
position: relative;
top: -40px;
left: -10px;
height: 30px;
background: blue;
border-radius: 80% 80% 80% 80%;
width: 30px;
}
.stick {
position: relative;
transform-origin: 50% 100%;
top: 40px;
margin-left: 50px;
float: left;
height: 70vh;
background: black;
width: 8px;
animation: swing var(--swing-time) ease-in-out infinite;
}
@keyframes swing {
0%,
100% {
transform: rotate(-6deg);
}
50% {
transform: rotate(8deg);
}
}
<div class="stick">
<div class="balloon">
</div></div>
<div class="stick">
<div class="balloon">
</div></div>
<div class="stick">
<div class="balloon">
</div>
</div>
<div class="stick">
<div class="balloon">
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句