Skip to content

Commit 2ebea44

Browse files
committed
Re-render with scrollable tables
1 parent c01398d commit 2ebea44

35 files changed

Lines changed: 6345 additions & 5468 deletions

docs/css/styles.css

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
padding: 0.5em 1em;
1919
border-radius: 5px;
2020
margin-bottom: 1em;
21+
max-width: 100%;
22+
overflow-x: auto;
23+
}
24+
25+
/* Strip the gray box from cell outputs that contain a table —
26+
the table's own scroll container handles border + shadow */
27+
28+
.cell-output-display:has(table) {
29+
background-color: transparent !important;
30+
padding: 0 !important;
31+
border-radius: 0;
32+
box-shadow: none;
2133
}
2234

2335
/* ============================================================
@@ -203,18 +215,16 @@ img {
203215
}
204216

205217
/* ============================================================
206-
TABLES: AESTHETICS ONLY
218+
TABLES: AESTHETICS
207219
============================================================ */
208220

209221
/* Alternating row shading */
210222

211-
table tr:nth-child(even) {
212-
background-color: #f5f5f5;
213-
}
223+
table tr:nth-child(even) { background-color: #f5f5f5; }
224+
table tr:nth-child(odd) { background-color: #ffffff; }
214225

215-
table tr:nth-child(odd) {
216-
background-color: #ffffff;
217-
}
226+
/* Hover row highlight */
227+
table tbody tr:hover { background-color: #fdf0f2; }
218228

219229
/* Cell padding and borders */
220230

@@ -225,23 +235,30 @@ table td {
225235
text-align: left;
226236
}
227237

228-
/* Crimson header with rounded top corners and white text */
238+
/* Table base.
239+
border-collapse: collapse (not separate) is required for
240+
position: sticky on thead th to work correctly.
241+
border-radius and box-shadow are applied to the scroll
242+
containers below instead of the table element itself. */
229243

230244
table {
231-
border-collapse: separate; /* required for border-radius on thead to work */
245+
border-collapse: collapse;
232246
border-spacing: 0;
233-
border: 1px solid #d0d0d0;
234-
border-radius: 6px;
235-
overflow: hidden; /* clips corners cleanly */
236247
background: #fff;
237-
box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
238248
}
239249

250+
/* Crimson sticky header.
251+
box-shadow replaces border-bottom because border-collapse: collapse
252+
causes cell borders on sticky elements to visually disappear mid-scroll. */
253+
240254
table thead th {
241255
background-color: #a51c30 !important;
242256
color: #ffffff !important;
243257
font-weight: 700 !important;
244-
border-color: #8b1628 !important;
258+
position: sticky;
259+
top: 0;
260+
z-index: 2;
261+
box-shadow: inset 0 -2px 0 #8b1628;
245262
}
246263

247264
/* ============================================================
@@ -315,23 +332,18 @@ figure figcaption {
315332
}
316333

317334
/* ============================================================
318-
TABLE LAYOUT: WRAPPING + SCROLLING
335+
TABLE LAYOUT: SCROLLING + NO SQUASHING
319336
============================================================ */
320337

321338
/*
322-
Strategy:
323-
- col { width: auto } neutralises Quarto's inline <col style="width: X%">
324-
which otherwise crushes narrow columns regardless of their content.
325-
- table-layout: auto + width: max-content tells the browser to size the
326-
table and each column purely by content. Short columns stay narrow,
327-
long ones get the space they need. No column ever squashes another.
328-
- Text wraps naturally in cells that genuinely have long content.
329-
Cells with short content (<~30 chars) won't wrap because the column
330-
will simply be wide enough to fit them on one line.
331-
- min-width: 80px on cells ensures no column collapses to unreadable.
332-
- The scroll container is div[aria-describedby] inside figure.quarto-float-tbl.
333-
The figure and its outer div are forced to display:block (not flex) so
334-
the scroll boundary starts at the true left edge of the table.
339+
Changes from previous version:
340+
─ white-space: nowrap replaces normal + overflow-wrap + word-break
341+
PRIMARY fix for the squashed/crushed look
342+
─ max-height + overflow-y: auto on containers → vertical scroll
343+
like kableExtra's scroll_box
344+
─ border-radius + box-shadow moved from table → scroll containers
345+
(they must live on the scroll container, not the table, for
346+
sticky headers to work)
335347
*/
336348

337349
/* 1. Neutralise Quarto's inline colgroup percentages */
@@ -347,23 +359,22 @@ table {
347359
width: max-content;
348360
}
349361

350-
/* 3. Cell text: wrap only when content is genuinely long */
362+
/* 3. Cell text: nowrap is the primary fix for squashing */
351363

352364
table th,
353365
table td {
354-
white-space: normal;
355-
overflow-wrap: break-word;
356-
word-break: break-word;
357-
min-width: 80px;
366+
white-space: nowrap;
367+
min-width: 60px;
358368
}
359369

360370
/* 4. Scroll containers for Quarto captioned tables (#tbl-*)
361371
Structure:
362-
div.quarto-float <- display:block
363-
figure.quarto-float-tbl <- display:block (NOT flex)
364-
figcaption
365-
div[aria-describedby] <- overflow-x:auto lives here
366-
table <- margins zeroed; width:max-content */
372+
div.cell-output-display <- transparent (overridden above)
373+
div.quarto-float <- display:block
374+
figure.quarto-float-tbl <- display:block (NOT flex)
375+
figcaption
376+
div[aria-describedby] <- scroll box + border lives here
377+
table <- margins zeroed; width:max-content */
367378

368379
div.quarto-float:has(figure.quarto-float-tbl) {
369380
display: block !important;
@@ -383,27 +394,31 @@ figure.quarto-float-tbl {
383394
figure.quarto-float-tbl > div[aria-describedby] {
384395
display: block;
385396
width: 100%;
397+
max-height: 450px;
386398
overflow-x: auto;
399+
overflow-y: auto;
387400
-webkit-overflow-scrolling: touch;
388401
box-sizing: border-box;
402+
border: 1px solid #d0d0d0;
403+
border-radius: 6px;
404+
box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
389405
}
390406

391407
figure.quarto-float-tbl > div[aria-describedby] > table {
392408
margin-left: 0;
393409
margin-right: 0;
394410
}
395411

396-
/* 5. Scroll container for Pandas DataFrames (cell output) */
412+
/* 5. Scroll container for Pandas DataFrames (bare cell output) */
397413

398-
.cell-output-display {
399-
max-width: 100% !important;
400-
overflow-x: auto !important;
414+
.cell-output-display:has(table.dataframe) {
415+
max-height: 450px;
416+
overflow-x: auto;
417+
overflow-y: auto;
401418
-webkit-overflow-scrolling: touch;
402-
}
403-
404-
.cell-output-display > div {
405-
max-width: 100% !important;
406-
overflow-x: auto !important;
419+
border: 1px solid #d0d0d0;
420+
border-radius: 6px;
421+
box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
407422
}
408423

409424
.cell-output-display table.dataframe,
@@ -419,7 +434,6 @@ figure.quarto-float-tbl > div[aria-describedby] > table {
419434
Error message handling
420435
============================================================ */
421436

422-
423437
/* Make long error messages scroll instead of stretching the page */
424438
.cell-output-stderr pre,
425439
.cell-output-stdout pre,

docs/index.html

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4789,6 +4789,15 @@
47894789
padding: 0.5em 1em;
47904790
border-radius: 5px;
47914791
margin-bottom: 1em;
4792+
max-width: 100%;
4793+
overflow-x: auto;
4794+
}
4795+
4796+
.cell-output-display:has(table) {
4797+
background-color: transparent !important;
4798+
padding: 0 !important;
4799+
border-radius: 0;
4800+
box-shadow: none;
47924801
}
47934802

47944803
footer.footer .nav-footer {
@@ -4929,12 +4938,10 @@
49294938
}
49304939

49314940

4932-
table tr:nth-child(even) {
4933-
background-color: #f5f5f5;
4934-
}
4935-
table tr:nth-child(odd) {
4936-
background-color: #ffffff;
4937-
}
4941+
table tr:nth-child(even) { background-color: #f5f5f5; }
4942+
table tr:nth-child(odd) { background-color: #ffffff; }
4943+
4944+
table tbody tr:hover { background-color: #fdf0f2; }
49384945

49394946
table th,
49404947
table td {
@@ -4944,19 +4951,19 @@
49444951
}
49454952

49464953
table {
4947-
border-collapse: separate;
4954+
border-collapse: collapse;
49484955
border-spacing: 0;
4949-
border: 1px solid #d0d0d0;
4950-
border-radius: 6px;
4951-
overflow: hidden;
49524956
background: #fff;
4953-
box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
49544957
}
4958+
49554959
table thead th {
49564960
background-color: #a51c30 !important;
49574961
color: #ffffff !important;
49584962
font-weight: 700 !important;
4959-
border-color: #8b1628 !important;
4963+
position: sticky;
4964+
top: 0;
4965+
z-index: 2;
4966+
box-shadow: inset 0 -2px 0 #8b1628;
49604967
}
49614968

49624969
.quarto-float-caption,
@@ -5021,10 +5028,8 @@
50215028

50225029
table th,
50235030
table td {
5024-
white-space: normal;
5025-
overflow-wrap: break-word;
5026-
word-break: break-word;
5027-
min-width: 80px;
5031+
white-space: nowrap;
5032+
min-width: 60px;
50285033
}
50295034

50305035
div.quarto-float:has(figure.quarto-float-tbl) {
@@ -5043,23 +5048,28 @@
50435048
figure.quarto-float-tbl > div[aria-describedby] {
50445049
display: block;
50455050
width: 100%;
5051+
max-height: 450px;
50465052
overflow-x: auto;
5053+
overflow-y: auto;
50475054
-webkit-overflow-scrolling: touch;
50485055
box-sizing: border-box;
5056+
border: 1px solid #d0d0d0;
5057+
border-radius: 6px;
5058+
box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
50495059
}
50505060
figure.quarto-float-tbl > div[aria-describedby] > table {
50515061
margin-left: 0;
50525062
margin-right: 0;
50535063
}
50545064

5055-
.cell-output-display {
5056-
max-width: 100% !important;
5057-
overflow-x: auto !important;
5065+
.cell-output-display:has(table.dataframe) {
5066+
max-height: 450px;
5067+
overflow-x: auto;
5068+
overflow-y: auto;
50585069
-webkit-overflow-scrolling: touch;
5059-
}
5060-
.cell-output-display > div {
5061-
max-width: 100% !important;
5062-
overflow-x: auto !important;
5070+
border: 1px solid #d0d0d0;
5071+
border-radius: 6px;
5072+
box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
50635073
}
50645074
.cell-output-display table.dataframe,
50655075
.cell-output-display > div > table.dataframe {
@@ -5197,6 +5207,7 @@ <h3 class="anchored" data-anchor-id="learning-objectives">Learning Objectives</h
51975207
<li>Load and analyze data using Python libraries and functions</li>
51985208
<li>Wrangle real-world datasets</li>
51995209
<li>Create clear visualizations with <code>Matplotlib</code> and <code>Seaborn</code></li>
5210+
<li>Train a simple machine learning model using <code>scikit-learn</code></li>
52005211
</ul>
52015212
</section>
52025213
<section id="lessons" class="level3">
@@ -5704,21 +5715,22 @@ <h3 class="anchored" data-anchor-id="installation-requirements">Installation Req
57045715
<span id="cb1-30"><a href="#cb1-30" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span>Load and analyze data using Python libraries and functions</span>
57055716
<span id="cb1-31"><a href="#cb1-31" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span>Wrangle real-world datasets</span>
57065717
<span id="cb1-32"><a href="#cb1-32" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span>Create clear visualizations with <span class="in">`Matplotlib`</span> and <span class="in">`Seaborn`</span></span>
5707-
<span id="cb1-33"><a href="#cb1-33" aria-hidden="true" tabindex="-1"></a></span>
5708-
<span id="cb1-34"><a href="#cb1-34" aria-hidden="true" tabindex="-1"></a><span class="fu">### Lessons</span></span>
5709-
<span id="cb1-35"><a href="#cb1-35" aria-hidden="true" tabindex="-1"></a>These materials were developed for a trainer-led workshop, but are also amenable to self-guided learning.</span>
5710-
<span id="cb1-36"><a href="#cb1-36" aria-hidden="true" tabindex="-1"></a></span>
5711-
<span id="cb1-37"><a href="#cb1-37" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span><span class="co">[</span><span class="ot">Workshop schedule (trainer-led learning)</span><span class="co">](schedule/schedule.qmd)</span></span>
5712-
<span id="cb1-38"><a href="#cb1-38" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span><span class="co">[</span><span class="ot">Self-learning</span><span class="co">](schedule/self-learning.qmd)</span></span>
5713-
<span id="cb1-39"><a href="#cb1-39" aria-hidden="true" tabindex="-1"></a></span>
5718+
<span id="cb1-33"><a href="#cb1-33" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span>Train a simple machine learning model using <span class="in">`scikit-learn`</span></span>
5719+
<span id="cb1-34"><a href="#cb1-34" aria-hidden="true" tabindex="-1"></a></span>
5720+
<span id="cb1-35"><a href="#cb1-35" aria-hidden="true" tabindex="-1"></a><span class="fu">### Lessons</span></span>
5721+
<span id="cb1-36"><a href="#cb1-36" aria-hidden="true" tabindex="-1"></a>These materials were developed for a trainer-led workshop, but are also amenable to self-guided learning.</span>
5722+
<span id="cb1-37"><a href="#cb1-37" aria-hidden="true" tabindex="-1"></a></span>
5723+
<span id="cb1-38"><a href="#cb1-38" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span><span class="co">[</span><span class="ot">Workshop schedule (trainer-led learning)</span><span class="co">](schedule/schedule.qmd)</span></span>
5724+
<span id="cb1-39"><a href="#cb1-39" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span><span class="co">[</span><span class="ot">Self-learning</span><span class="co">](schedule/self-learning.qmd)</span></span>
57145725
<span id="cb1-40"><a href="#cb1-40" aria-hidden="true" tabindex="-1"></a></span>
5715-
<span id="cb1-41"><a href="#cb1-41" aria-hidden="true" tabindex="-1"></a><span class="fu">### Installation Requirements</span></span>
5716-
<span id="cb1-42"><a href="#cb1-42" aria-hidden="true" tabindex="-1"></a></span>
5717-
<span id="cb1-43"><a href="#cb1-43" aria-hidden="true" tabindex="-1"></a>Download the most recent version of the **Graphical Installer** of Anaconda, Anaconda Navigator, for the appropriate operating system of your computer using the link below:</span>
5718-
<span id="cb1-44"><a href="#cb1-44" aria-hidden="true" tabindex="-1"></a></span>
5719-
<span id="cb1-45"><a href="#cb1-45" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span><span class="co">[</span><span class="ot">Anaconda</span><span class="co">](https://www.anaconda.com/download/success)</span></span>
5720-
<span id="cb1-46"><a href="#cb1-46" aria-hidden="true" tabindex="-1"></a></span>
5721-
<span id="cb1-47"><a href="#cb1-47" aria-hidden="true" tabindex="-1"></a>Once downloaded, run the installer and follow the prompts to complete the installation. The **default settings** should work for most users, but you can customize the installation if needed. This will install a new program called Anaconda Navigator.</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button" data-in-quarto-modal><i class="bi"></i></button></div>
5726+
<span id="cb1-41"><a href="#cb1-41" aria-hidden="true" tabindex="-1"></a></span>
5727+
<span id="cb1-42"><a href="#cb1-42" aria-hidden="true" tabindex="-1"></a><span class="fu">### Installation Requirements</span></span>
5728+
<span id="cb1-43"><a href="#cb1-43" aria-hidden="true" tabindex="-1"></a></span>
5729+
<span id="cb1-44"><a href="#cb1-44" aria-hidden="true" tabindex="-1"></a>Download the most recent version of the **Graphical Installer** of Anaconda, Anaconda Navigator, for the appropriate operating system of your computer using the link below:</span>
5730+
<span id="cb1-45"><a href="#cb1-45" aria-hidden="true" tabindex="-1"></a></span>
5731+
<span id="cb1-46"><a href="#cb1-46" aria-hidden="true" tabindex="-1"></a><span class="ss">- </span><span class="co">[</span><span class="ot">Anaconda</span><span class="co">](https://www.anaconda.com/download/success)</span></span>
5732+
<span id="cb1-47"><a href="#cb1-47" aria-hidden="true" tabindex="-1"></a></span>
5733+
<span id="cb1-48"><a href="#cb1-48" aria-hidden="true" tabindex="-1"></a>Once downloaded, run the installer and follow the prompts to complete the installation. The **default settings** should work for most users, but you can customize the installation if needed. This will install a new program called Anaconda Navigator.</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button" data-in-quarto-modal><i class="bi"></i></button></div>
57225734
</div></div></div></div></div>
57235735
</div> <!-- /content -->
57245736
<footer class="footer">

0 commit comments

Comments
 (0)