2

I want ABCD on the left and DATE should be in the center. How to achieve this?

.flex-items {
  display: flex;
  justify-content: flex-start;
  padding-left: 17px;
}

.abcd1 {}

.date1 {
  /*this item should be in the center.*/
}
<div class="flex-items">
  <div class="abcd1">ABCD</div>
  <div class="date1">DATE</div>
</div>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
Aditya
  • 2,358
  • 6
  • 35
  • 61

3 Answers3

3

Try this code

.flex-items {

  display: flex;
  justify-content: flex-start;
  padding-left: 17px;
}

.abcd1 {

}

.date1 {
    margin-left: auto;
    margin-right: auto;
}
<div class="flex-items">

<div class="abcd1">ABCD</div>
<div class="date1">DATE</div>

</div>
Abhishek Shah
  • 436
  • 1
  • 3
  • 12
0

See below. Hope this helps.

.flex-items {
  display: flex;
  padding-left: 17px;
  text-align: center;
}

.date1 {
  flex: 1;
}
<div class="flex-items">
  <div class="abcd1">ABCD</div>
  <div class="date1">DATE</div>
</div>
Gerard
  • 15,418
  • 5
  • 30
  • 52
0

Text-align: center works when there is a width provided. This also works:

.flex-items {
     display: flex;
     justify-content: flex-start;
     padding-left: 17px;
}
.abcd1 {
          
}     
.date1 {
     /*this item should be in the center.*/
     text-align: center;
     width: 100%;
}
    <div class="flex-items">
    <div class="abcd1">ABCD</div>
    <div class="date1">DATE</div>
</div>
Anh K
  • 96
  • 5