'CSS Flexbox with position absolute confusion

I'm confused how this works could someone walk me through what exactly happened?

body,
html {
  padding: 0;
  margin: 0;
  height: 100vh;
  width: 100%;
}

.chat-break {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;

}

.chat-break .line {
  border-bottom: 1px solid #ddd;
  width: 100%;
}

.chat-break .date {
  color: #B5B5B5;
  position: absolute;
  background-color: #fff;
  padding-left: 8px;
  padding-right: 8px;
  
}
<div class="chat-break">
    <div class="line">
    </div>
    
    <p class="date">Today</p>
</div>
  

My understanding:

  • .chat-break flexbox has two elements .line and .date.
  • ...but after using position: absolute on .date its no longer its own element inside the flexbox?
  • Then why is "Today" being centered on the line?
css


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source