我有以下HTML类:
<div class="image-changing">
<ion-icon name="ios-arrow-back" class="arrow-back"></ion-icon>
<ion-icon name="ios-arrow-back" class="arrow-back"></ion-icon>
<span class="circle"></span>
<ion-icon name="ios-arrow-forward" class="arrow-forward"></ion-icon>
<ion-icon name="ios-arrow-forward" class="arrow-forward"></ion-icon>
</div>
以下CSS:
.arrow-back {
position: relative + 100px;
// margin-right: auto;
// align: center;
float:left;
font-size:60px;
color:white;
}
.arrow-forward {
left: 20%;
float:right;
font-size:60px;
color:white;
position: calc(100% - 1 em);
}
.image-changing {
width: 80%; margin: 0 auto;
}
有没有人知道如何将五个组件对齐?
答案 0 :(得分:1)
尝试添加以下属性:
.image-changing { text-align: center;}
.arrow-back, .circle, .arrow-forward { display: inline-block; }
答案 1 :(得分:0)
这应该可以解决问题。使用具有居中元素的flexbox。
/* .css */
.test6 {
height: Calc(1em + 5px * 3);
}
.arrow-back {
font-size: 60px;
color: white;
}
.arrow-forward {
font-size: 60px;
color: white;
}
.image-changing {
width: 80%;
margin: 0 auto;
display: flex;
justify-content: center;
}