丸の中に扇型を入れたのですが、アニメーションで動かすと、扇型が外にでてぶっ飛んでしまいます。丸と扇型合わせて一つの図形のように連動させたいです。
丸の挙動は理想通りなのですが・・・
どうやったらくっついたままにできますか?
以下コード
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title></title>
<style>
*{margin:0px; padding:0px;}
#box1 {
border-radius: 50%;
width:100px; height:100px;
background:black;
}
#box2 {
border-radius: 100px 0px 50px 50px / 100px 0px 0px 0px;
width:50px; height:50px;
background:yellow;
}
div {
width:100px; height:100px;
animation-name: myanimation;
animation-duration: 10s;
animation-iteration-count: infinite;
}
@keyframes myanimation {
45% {
transform: translate(700px, 0px) rotate(360deg);
}
50% {
transform: translate(0px, 500px) rotate(720deg);
}
95% {
transform: translate(700px, 500px) rotate(1080deg);
}
100%{
transform: translate(0px,0px) rotate(1440deg);
}
}
</style>
</head>
<body>
<div id="box1">
<div id="box2">
</div>
</div>
</body>
</html>
みんなの回答 1 件
ちょっとよくイメージできませんでしたがこんな感じですか?
style部分のみ変更しましたのでstyle部分のみですが
<style>
*{margin:0px; padding:0px;}
#box1 {
position: relative;
border-radius: 50%;
width:100px; height:100px;
background:black;
}
#box2 {
position: absolute;
top: 0;
left: 0;
border-radius: 100px 0px 50px 50px / 100px 0px 0px 0px;
width:50px; height:50px;
background:yellow;
}
#box1 {
animation-name: myanimation;
animation-duration: 10s;
animation-iteration-count: infinite;
}
@keyframes myanimation {
45% {
transform: translate(700px, 0px) rotate(360deg);
}
50% {
transform: translate(0px, 500px) rotate(720deg);
}
95% {
transform: translate(700px, 500px) rotate(1080deg);
}
100%{
transform: translate(0px,0px) rotate(1440deg);
}
}
</style>
関連するトピックス