1

changing overflow property of the second container to "hidden" somehow breaks the surrounding container:

.title {
  margin-top: 100px;
  margin-left: 50px;
  font-size: 30px;
  position: absolute;
  
  /* debug */
  background-color: blue;
}

.first {
  /* debug */
  background-color: green;
}

.second {
  overflow: hidden;
  display: inline-block;
  
  /* debug */
  background-color: red;
}
<div>
  <div class="title">
    <span class="first">Start</span>
    <span class="second"> end</span>
  </div>
</div>
connexo
  • 53,704
  • 14
  • 91
  • 128
qucumbah
  • 73
  • 4

1 Answers1

1

The reason is not the overflow, it's display: inline-block;:

.title {
  margin-top: 100px;
  margin-left: 50px;
  font-size: 30px;
  position: absolute;
  /* debug */
  background-color: blue;
}

.first {
  /* debug */
  background-color: green;
}

.second {
  overflow: hidden;

  /* debug */
  background-color: red;
}
<div>
  <div class="title">
    <span class="first">Start</span>
    <span class="second"> end</span>
  </div>
</div>

Edit:

If it must be display: inline-block;, add vertical-align: text-bottom;:

.title {
  margin-top: 100px;
  margin-left: 50px;
  font-size: 30px;
  position: absolute;
  /* debug */
  background-color: blue;
}

.first {
  /* debug */
  background-color: green;
}

.second {
  overflow: hidden;
  display: inline-block;
  vertical-align: text-bottom;
  /* debug */
  background-color: red;
}
<div>
  <div class="title">
    <span class="first">Start</span>
    <span class="second"> end</span>
  </div>
</div>
Community
  • 1
  • 1
connexo
  • 53,704
  • 14
  • 91
  • 128