I'm messing around with a code searching ui that lists matched lines by file along with the surrounding code. The matched lines and their surroundings are listed inside a container div with overflow: auto
so that the code can be scrolled.
Here is how the html and css are laid out:
.container {
width: 200px;
overflow: auto;
border: 2px solid #CCC;
}
.match:first-child {
border-top: none;
}
.match {
border-top: 1px solid red;
}
span {
white-space: pre;
}
<div class="container">
<div class="match">
<div class="line">
<span>This content is so long that it ends up going beyond the edge of the container. Good thing we are using overflow: auto so we can scroll!</span>
</div>
<div class="line">
<span>Another line that is too long to fit into the container.</span>
</div>
<div class="line">
<span>There can be many lines in each match, but the border should only be between the matches, not the lines.</span>
</div>
</div>
<div class="match">
<div class="line">
<span>The second line. Does it matter how long this line is? Will the line border extend now that this line is overflowing?</span>
</div>
</div>
</div>
The problem is that when the content within the .line
divs extends beyond the .container
, the borders on the .match
elements only extend to the width of the .container
.
Is there any way to make the .match
elements extend to the entire width of the container so that the border extends the entire width of the scrollable area?