我试图让我的三角形围绕我的大学作业旋转,但我在让我的三角形响应时遇到了问题。
蓝紫色三角形应该在橙色方框内旋转,大小应该像其他形状一样响应,但我的知识非常有限。
有什么办法可以把我的小三角形压成正方形吗?
我提前感谢您的帮助...
body {
background-color: white;
}
svg {
position: absolute;
width: 100vw;
height: 100vh;
fill:white;
}
.box {
position: relative;
width: 30vw;
height: 30vw;
fill:white;
stroke:orange;
stroke-width: 1px;
}
.circleAndTriangle {
animation: colorChange 5s linear infinite;
}
.triangle {
transform-origin: 50vw 35vw;
position: absolute;
animation: rotatingTriangle 5s linear reverse infinite;
}
@keyframes colorChange {
0% {fill:blue }
100% {fill:red}
}
@keyframes rotatingTriangle {
0% {transform: rotate(0deg);}
100% {transform: rotate(-360deg);}
}
<!DOCTYPE html>
<html lang="en-UK">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link type="text/css" href="https://cdn.jsdelivr.net/npm/reset-css@3.0.0/reset.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<title>Rotating Study</title>
</head>
<body>
<svg>
<rect x="35vw" y="20vw" rx="0px" ry="0px" class="box"/>
<g class="circleAndTriangle">
<circle cx= "50vw" cy="35vw" r="1.5vw" class="circle"/>
<polygon points="250,150,280,150,265,175" class="triangle"/>
</g>
</svg>
</body>
</html>