我有两张透明背景的图片,需要将它们叠放在一起并保持相同的定位:
我使用了一个伪元素
我认为应该涉及到
如果涉及到完全不同的方法,即使需要使用
非常感谢。
- 1个旋转的(在下方)
- 1个固定的(在上方)
我使用了一个伪元素
::after
来处理固定的那个图片,但无法使其位置和大小与旋转的那个图片相匹配。我认为应该涉及到
background-size
属性,但没能正确地使用它。如果涉及到完全不同的方法,即使需要使用
::after
伪类,也希望能得到任何建议。非常感谢。
body{
width: 100%;
height: 100%;
background-color: #000;
text-align: center;
color: #fff;
}
.main-container{
background-color: #00f;
width: 50%;
margin: 0 auto;
}
.engine-container{
}
.engine-complete{
position: relative;
width: 100%;
height: auto;
margin: 0 auto;
}
.engine-complete::after{
content: "";
position: absolute;
width: 191px;
height: 192px;
top: 1px;
left: 0;
background-image: url(https://image.ibb.co/jOqNma/engine1_crpd.png);
}
.engine-rotating{
width: 50%;
height: auto;
}
.spin {
animation-duration: 15s;
animation-name: spin;
animation-iteration-count: infinite;
animation-timing-function:linear;
animation-play-state: running;
}
@keyframes spin {
from {
transform:rotate(360deg);
}
to {
transform:rotate(0deg);
}
}
<div class="main-container">
<h1>spinning engine</h1>
<div class="engine-container">
<div class="engine-complete">
<img src="https://image.ibb.co/nwOKXF/engine1.png" width=191 height=192 class="engine-rotating spin"/>
</div>
</div>
</div>
::after
伪类来实现,你觉得呢? - Fred::after
伪类时,也遇到了同样的问题。 - Fred