我如何分组所有具有绝对位置的元素,并将它们集中在一个父级div中?我也将使用jQuery添加和删除每个元素,并希望它们自动居中。 因此,在我的jsfiddle示例中,我想将所有三张卡片组合在一起。谢谢。css我怎么能中心多个元素的绝对位置
https://jsfiddle.net/ksha09jk/2/
HTML
<div class='wrap'>
<li class='card card1'>Q</li>
<li class='card card2'>K</li>
<li class='card card3'>A</li>
</div>
CSS
.wrap{
position: relative;
height: 100px;
background-color: green;
}
.card{
width: 43px;
height: 60px;
border:1px solid black;
border-radius: 5px;
display: inline-block;
background-color: white;
}
.card1{
position: absolute;
top:15px;
left: 0px;
}
.card2{
position: absolute;
top:15px;
left: 30px;
}
.card3{
position: absolute;
top:15px;
left: 60px;
}
这就是我要找的。谢谢! – lys916
@ lys916欢迎您) –
有没有一种方法可以为每张卡片附上绝对位置?我没有意识到你已经删除了你的版本。当我点击它时,我正在寻找一些定位动画。 – lys916