Many questions have been raised about Bootstrap, Tables, and responsiveness. However, I have yet to find one that addresses my specific issue with getting a particular cell (<td>
element) to:
(a) Fill the available space, stopping at the window boundaries (i.e., be fluid), and
(b) Add horizontal scrollbars if the cell would be too large.
Objective:
https://i.sstatic.net/aRxEd.png
Current Solution:
Here is what I have come up with so far. Points to consider:
- I am not using any custom CSS, only the one provided by Bootstrap 4.1.3
- The
is commented out as I do not want the entire table to be scrollable.<div class="table-responsive">
- The
part successfully adds a vertical scrollbar when the log has many lines, but it does not add a horizontal scrollbar.<pre class="pre-scollable">
- Attempts to wrap the
results-log
cell in a bootstrapclass="container-fluid"
div did not yield the desired results. - Using
achieves the horizontal scrollbar but sacrifices responsiveness.<pre class="pre-scollable" style="width: 250px; overflow-x: scroll">
- Adjusting
width: inherit
does not resolve the issue either. - The entire content is within a
and another div, which I believe should not impact this specific problem.<main class="container-fluid-page">
<!DOCTYPE html>
<head>
...
</head>
<body>
<!-- other stuff that doesn't matter -->
<main class="container-fluid-page">
<div id="content">
<div id="results">
<h2>Results:</h2>
<!--<div class="table-responsive">-->
<table class="table table-sm">
<tbody>
<tr>
<th>Status</th>
<td>
<div id="results-status">
foo
</div>
</tr>
<tr>
<th>ReturnValue</th>
<td>
<div id="results-return-value">
<pre><code class="json">{
"__type__": "RecordRef",
"name": "foo"
}</code></pre>
</div>
</td>
</tr>
<tr>
<th>ReturnValue</th>
<td>
<div id="results-log">
<pre class="pre-scollable"><code>2019-05-23 07:51:32Z Log text
2019-05-23 07:51:33Z log text that can have a really really really long line in it and I want to scroll
2019-05-23 07:51:34Z log text</code></pre>
</div>
</td>
</tr>
</tbody>
</table>
<!--</div>--> <!-- class="table-responsive" -->
</div> <!-- id=results -->
</div> <!-- id=content -->
</main>
</body>
Edits:
- Removed
col-*
from<th>
and<td>
definitions.