Skip to content

Commit 67d7537

Browse files
committed
Fixing table css in lesson 10
1 parent 1ab2a30 commit 67d7537

6 files changed

Lines changed: 289 additions & 80 deletions

File tree

css/styles.css

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ main img,
7777
display: block;
7878
margin-left: auto;
7979
margin-right: auto;
80-
/* Optional: vertical space above/below */
8180
margin-top: 1em;
8281
margin-bottom: 1em;
8382
}
@@ -181,11 +180,11 @@ img {
181180
}
182181

183182

184-
/* --- Styled Markdown Tables --- */
183+
/* --- Styled Tables --- */
185184

185+
/* NOTE: do NOT force width: 100% here.
186+
That breaks horizontal scrolling of very wide tables. */
186187
table {
187-
/* Markdown tables: use full content width */
188-
width: 100%;
189188
border-collapse: collapse;
190189
border: 1px solid #d0d0d0; /* outer border */
191190
border-radius: 6px;
@@ -200,7 +199,7 @@ table th,
200199
table td {
201200
border: 1px solid #e5e5e5; /* internal grid lines */
202201
padding: 0.55em 0.75em;
203-
text-align: left; /* make all table text left-aligned */
202+
text-align: left; /* left-align all table text */
204203
}
205204

206205
table th {
@@ -209,18 +208,22 @@ table th {
209208
color: #333;
210209
}
211210

212-
213-
/* --- Crimson-Themed Table Headers (Markdown + kable + DT) --- */
214-
211+
/* Crimson header row */
215212
table thead th {
216213
background: #a51c30 !important; /* crimson */
217214
color: #ffffff !important; /* white text */
218215
font-weight: 700 !important; /* bold */
219216
border: 1px solid #8b1628 !important; /* darker crimson border */
220217
}
221218

219+
/* Markdown/Quarto tables: full content width only when inside Quarto's wrapper.
220+
This avoids stretching Pandas DataFrames. */
221+
.quarto-table table:not(.dataframe) {
222+
width: 100%;
223+
}
224+
222225

223-
/* Left align table captions generated by Quarto (no special background) */
226+
/* Captions left-aligned, no special background */
224227
.quarto-float-tbl .quarto-float-caption,
225228
.quarto-float .quarto-float-caption,
226229
table caption {
@@ -233,7 +236,8 @@ table caption {
233236
}
234237

235238

236-
/* Center Quarto figures and their contents */
239+
/* --- Figures --- */
240+
237241
.quarto-figure,
238242
.figure, /* your custom .figure block */
239243
figure {
@@ -275,8 +279,8 @@ figure figcaption {
275279
}
276280

277281

278-
/* Make Quarto columns stretch to equal height and center their content vertically
279-
so images inside a column appear in the vertical middle of the column. */
282+
/* --- Columns Layout --- */
283+
280284
.columns {
281285
display: flex !important;
282286
align-items: stretch !important; /* ensure columns match height */
@@ -293,27 +297,25 @@ figure figcaption {
293297

294298

295299
/* ----------------------------------------------------------
296-
Wide Pandas tables (DataFrames):
297-
- Let the table be as wide as it needs (many columns).
298-
- Constrain the gray output box to the page width.
299-
- Provide horizontal scroll inside that box.
300+
Wide Pandas DataFrames:
301+
- Gray output box constrained to page width.
302+
- Inner DataFrame table can be wider.
303+
- Horizontal scroll inside the box.
300304
-----------------------------------------------------------*/
301305

302-
/* Constrain the output boxes and allow horizontal scroll */
303-
.cell-output,
306+
/* Constrain output boxes to content width and allow horizontal scroll */
304307
.cell-output-display {
305-
max-width: 100%;
306-
overflow-x: auto; /* show horizontal scrollbar when table is wide */
308+
max-width: 100% !important;
309+
overflow-x: auto !important;
307310
}
308311

309-
/* Pandas DataFrame tables: use intrinsic width, not forced 100% */
310-
table.dataframe {
311-
width: auto !important; /* don't stretch to 100% of container */
312-
max-width: none !important; /* allow width beyond container; scroll will handle it */
312+
/* Pandas DataFrame tables should use intrinsic width, not stretch */
313+
.cell-output-display table.dataframe {
314+
width: auto !important;
315+
max-width: none !important;
313316
}
314317

315-
/* Some Pandas/Quarto variants wrap the dataframe in an extra div; handle those too */
316-
.cell-output-display > table.dataframe,
318+
/* Some variants wrap the dataframe in another div; handle those too */
317319
.cell-output-display > div > table.dataframe {
318320
width: auto !important;
319321
max-width: none !important;

docs/css/styles.css

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ main img,
7777
display: block;
7878
margin-left: auto;
7979
margin-right: auto;
80-
/* Optional: vertical space above/below */
8180
margin-top: 1em;
8281
margin-bottom: 1em;
8382
}
@@ -181,11 +180,11 @@ img {
181180
}
182181

183182

184-
/* --- Styled Markdown Tables --- */
183+
/* --- Styled Tables --- */
185184

185+
/* NOTE: do NOT force width: 100% here.
186+
That breaks horizontal scrolling of very wide tables. */
186187
table {
187-
/* Markdown tables: use full content width */
188-
width: 100%;
189188
border-collapse: collapse;
190189
border: 1px solid #d0d0d0; /* outer border */
191190
border-radius: 6px;
@@ -200,7 +199,7 @@ table th,
200199
table td {
201200
border: 1px solid #e5e5e5; /* internal grid lines */
202201
padding: 0.55em 0.75em;
203-
text-align: left; /* make all table text left-aligned */
202+
text-align: left; /* left-align all table text */
204203
}
205204

206205
table th {
@@ -209,18 +208,22 @@ table th {
209208
color: #333;
210209
}
211210

212-
213-
/* --- Crimson-Themed Table Headers (Markdown + kable + DT) --- */
214-
211+
/* Crimson header row */
215212
table thead th {
216213
background: #a51c30 !important; /* crimson */
217214
color: #ffffff !important; /* white text */
218215
font-weight: 700 !important; /* bold */
219216
border: 1px solid #8b1628 !important; /* darker crimson border */
220217
}
221218

219+
/* Markdown/Quarto tables: full content width only when inside Quarto's wrapper.
220+
This avoids stretching Pandas DataFrames. */
221+
.quarto-table table:not(.dataframe) {
222+
width: 100%;
223+
}
224+
222225

223-
/* Left align table captions generated by Quarto (no special background) */
226+
/* Captions left-aligned, no special background */
224227
.quarto-float-tbl .quarto-float-caption,
225228
.quarto-float .quarto-float-caption,
226229
table caption {
@@ -233,7 +236,8 @@ table caption {
233236
}
234237

235238

236-
/* Center Quarto figures and their contents */
239+
/* --- Figures --- */
240+
237241
.quarto-figure,
238242
.figure, /* your custom .figure block */
239243
figure {
@@ -275,8 +279,8 @@ figure figcaption {
275279
}
276280

277281

278-
/* Make Quarto columns stretch to equal height and center their content vertically
279-
so images inside a column appear in the vertical middle of the column. */
282+
/* --- Columns Layout --- */
283+
280284
.columns {
281285
display: flex !important;
282286
align-items: stretch !important; /* ensure columns match height */
@@ -293,27 +297,25 @@ figure figcaption {
293297

294298

295299
/* ----------------------------------------------------------
296-
Wide Pandas tables (DataFrames):
297-
- Let the table be as wide as it needs (many columns).
298-
- Constrain the gray output box to the page width.
299-
- Provide horizontal scroll inside that box.
300+
Wide Pandas DataFrames:
301+
- Gray output box constrained to page width.
302+
- Inner DataFrame table can be wider.
303+
- Horizontal scroll inside the box.
300304
-----------------------------------------------------------*/
301305

302-
/* Constrain the output boxes and allow horizontal scroll */
303-
.cell-output,
306+
/* Constrain output boxes to content width and allow horizontal scroll */
304307
.cell-output-display {
305-
max-width: 100%;
306-
overflow-x: auto; /* show horizontal scrollbar when table is wide */
308+
max-width: 100% !important;
309+
overflow-x: auto !important;
307310
}
308311

309-
/* Pandas DataFrame tables: use intrinsic width, not forced 100% */
310-
table.dataframe {
311-
width: auto !important; /* don't stretch to 100% of container */
312-
max-width: none !important; /* allow width beyond container; scroll will handle it */
312+
/* Pandas DataFrame tables should use intrinsic width, not stretch */
313+
.cell-output-display table.dataframe {
314+
width: auto !important;
315+
max-width: none !important;
313316
}
314317

315-
/* Some Pandas/Quarto variants wrap the dataframe in an extra div; handle those too */
316-
.cell-output-display > table.dataframe,
318+
/* Some variants wrap the dataframe in another div; handle those too */
317319
.cell-output-display > div > table.dataframe {
318320
width: auto !important;
319321
max-width: none !important;

0 commit comments

Comments
 (0)