【发布时间】:2021-05-03 02:19:33
【问题描述】:
我正在尝试将 SVG 从 0 度设置为 360 度。但是,如果我使用 transform: rotate 属性,那么 svg 会在浏览器调整大小时失去其位置并且它不会居中对齐。我使用转换原点到 50%。但是 svg 失去了它的位置。
HTML:
<div id="hexagon-spinner">
<Hexagon className="hexagon-loader" viewBox="0 0 65.103 75.174" />
</div>
#hexagon-spinner {
position: fixed;
width: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.7);
z-index: 9999;
}
.hexagon-loader {
animation-name: spin;
animation-duration: 0.8s;
/* Things added */
animation-iteration-count: infinite;
transform-origin: -50% 50%;
display: inline-block;
position: absolute;
top: 50%;
left: 50%;
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
【问题讨论】:
-
也请分享html代码..
-
@MinalChauhan 用 html 更新问题