0

Could someone explain to me this strange behavior?

.wrapper {
  width: 500px;
}
.container {
  background: blue;
  flex-direction: row;
  padding: 10px;
  display: flex;
  margin-bottom: 10px;
}

a {
  margin-left: 10px;
  background: pink;
  align-self: start;
}
#title {
  font-size: 21px;
  line-height: 28px;
}
<div class="wrapper">
  <div class="container">
    <a id="title" href="#">Deserunt exercitationem exercitationem.</a>
    <a href="#">Test</a>
  </div>
  <div class="container">
    <a id="title" href="#">Deserunt autem non voluptatem velit exercitationem.</a>
    <a href="#">Test</a>
  </div>
</div>

https://codepen.io/rgdgu8uz2llu/pen/VwmwjLa

Why is the flex item #title in the second row so stretched, while in the first row as I expect? How do I make #title width fit to content, as inline?

Is there any way to fix it?

Thanks!

skolind
  • 1,724
  • 6
  • 28
  • 51

0 Answers0