0

I have the following HTML class:

<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>

And the following 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;
}

Does anyone have any idea how to center align the five components?

Antti29
  • 2,953
  • 12
  • 34
  • 36
Yannis_K
  • 7
  • 1
  • 6

2 Answers2

1

try by adding following properties:

.image-changing { text-align: center;} 
.arrow-back, .circle, .arrow-forward  { display: inline-block; }
brijrajsinh
  • 453
  • 3
  • 11
0

This should do the trick. Using a flexbox with the elements centered.

.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;
}
<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>
Alireza
  • 100,211
  • 27
  • 269
  • 172
Gerard
  • 15,418
  • 5
  • 30
  • 52