CSS background image rotation

2019-08-01 16:10发布

I'm making rotating container. Actually I've already made.. but there is the problem: background image is loaded in half (the container is loaded in half).

The code is:

  @keyframes rotate-ornament {
  from {
  -webkit-transform: rotate(0deg);
  }
  to {
   -webkit-transform: rotate(360deg);
  }
  }
  @-webkit-keyframes rotate-ornament {
  from {
  -webkit-transform: rotate(0deg);
  }
  to {
  -webkit-transform: rotate(360deg);
  }
  }
  @-moz-keyframes rotate-ornament {
  from {
 -webkit-transform: rotate(0deg);
 }
 to {
 -webkit-transform: rotate(360deg);
 }
 }
 @-ms-keyframes rotate-ornament {
 from {
 -webkit-transform: rotate(0deg);
 }
 to {
 -webkit-transform: rotate(360deg);
 }
 }

.ornament {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
width:100%;
height:100%;
display:block;
z-index: -1;
}


.ornament {
background:transparent url('images/ornament.png') no-repeat;
background-size: 100%;
z-index: -1;
-moz-animation: rotate-ornament 100s linear infinite;
-ms-animation: rotate-ornament 100s linear infinite;
-o-animation: rotate-ornament 100s linear infinite;
-webkit-animation: rotate-ornament 100s linear infinite;
animation: rotate-ornament 100s linear infinite;
}

Thanks in advance!

1条回答
一纸荒年 Trace。
2楼-- · 2019-08-01 16:23

The issue is height:100%

I changed that height of the div ".ornament" (via chrome inspector) to the actual height of the background image (1386px) and it works fine.

查看更多
登录 后发表回答