Skip to content

Commit 5dd7413

Browse files
committed
still trying to fix tables
1 parent 67d7537 commit 5dd7413

3 files changed

Lines changed: 157 additions & 76 deletions

File tree

css/styles.css

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
/* Alternative rows in tables are gray */
1+
/* ============================================================
2+
GENERAL TABLE + QUARTO STYLING
3+
============================================================ */
4+
5+
/* Alternative rows in Bootstrap-styled tables are gray */
26
.table tr:nth-child(even) {
37
background-color: #f5f5f5;
48
}
59

610

7-
/* For Quarto code output blocks */
11+
/* For Quarto code output blocks (including Pandas tables) */
812
.cell-output,
913
.cell-output-stdout,
1014
.cell-output-stderr,
1115
.cell-output-display {
12-
background-color: #f5f5f5 !important; /* Light gray */
16+
background-color: #f5f5f5 !important; /* Light gray background */
1317
padding: 0.5em 1em;
1418
border-radius: 5px;
1519
margin-bottom: 1em;
1620
}
1721

1822

19-
/* Stretch left footer across all columns for Quarto footers */
23+
/* ============================================================
24+
FOOTER
25+
============================================================ */
26+
2027
footer.footer .nav-footer {
2128
display: block !important;
2229
max-width: 100vw;
@@ -46,32 +53,39 @@ footer.footer .nav-footer-right {
4653
}
4754

4855

56+
/* ============================================================
57+
NAVBAR (HARVARD CRIMSON THEME)
58+
============================================================ */
59+
4960
/* Harvard Crimson: #A51C30 */
50-
/* For Quarto Bootstrap dark navbars: */
5161
.navbar,
5262
.navbar-dark {
5363
background-color: #a51c30 !important;
5464
}
5565

56-
/* For navbar items and hover/focus states */
66+
/* Navbar items and hover/focus states */
5767
.navbar .nav-link,
5868
.navbar .navbar-brand {
5969
color: #fff !important;
6070
}
6171

6272
.navbar .nav-link:hover,
6373
.navbar .nav-link:focus {
64-
color: #ffd700 !important; /* gold/yellow hover, optional */
74+
color: #ffd700 !important; /* gold/yellow hover */
6575
}
6676

67-
/* If your navbar is light/white by default, also force text to white: */
77+
/* If navbar is light by default, also force text to white */
6878
.navbar-light .navbar-nav .nav-link,
6979
.navbar-light .navbar-brand {
7080
color: #fff !important;
7181
}
7282

7383

74-
/* Center all images that are direct children of the main content (not inside tables or callouts) */
84+
/* ============================================================
85+
IMAGES & TITLE BLOCK
86+
============================================================ */
87+
88+
/* Center images that are direct children of main content / Quarto figures */
7589
main img,
7690
.quarto-figure img {
7791
display: block;
@@ -81,8 +95,7 @@ main img,
8195
margin-bottom: 1em;
8296
}
8397

84-
85-
/* Remove the box styling from the title block */
98+
/* Remove box styling from title block */
8699
.quarto-title-block {
87100
background: none !important;
88101
box-shadow: none !important;
@@ -92,8 +105,7 @@ main img,
92105
text-align: left !important;
93106
}
94107

95-
96-
/* Hide only the author, affiliation, date, subtitle, etc */
108+
/* Hide author, affiliation, date, subtitle, etc. */
97109
.quarto-title-author,
98110
.quarto-title-affiliation,
99111
.quarto-title-date,
@@ -114,14 +126,16 @@ img {
114126
}
115127

116128

117-
/* Hide breadcrumbs for both possible classnames */
129+
/* Hide breadcrumbs */
118130
.quarto-breadcrumbs,
119131
.quarto-page-breadcrumbs {
120132
display: none !important;
121133
}
122134

123135

124-
/* --- Refined, crimson-themed Quarto Tabsets --- */
136+
/* ============================================================
137+
TABSETS
138+
============================================================ */
125139

126140
.panel-tabset {
127141
border: 1px solid #e0e0e0; /* lighter outline */
@@ -180,10 +194,15 @@ img {
180194
}
181195

182196

183-
/* --- Styled Tables --- */
197+
/* ============================================================
198+
TABLES
199+
============================================================ */
184200

185-
/* NOTE: do NOT force width: 100% here.
186-
That breaks horizontal scrolling of very wide tables. */
201+
/*
202+
Base table styling (applies to markdown tables AND Pandas).
203+
NOTE: we intentionally do NOT set width: 100% here so that
204+
very wide tables can scroll inside their containers.
205+
*/
187206
table {
188207
border-collapse: collapse;
189208
border: 1px solid #d0d0d0; /* outer border */
@@ -208,22 +227,29 @@ table th {
208227
color: #333;
209228
}
210229

211-
/* Crimson header row */
230+
/* Crimson header row styling */
212231
table thead th {
213232
background: #a51c30 !important; /* crimson */
214233
color: #ffffff !important; /* white text */
215234
font-weight: 700 !important; /* bold */
216235
border: 1px solid #8b1628 !important; /* darker crimson border */
217236
}
218237

219-
/* Markdown/Quarto tables: full content width only when inside Quarto's wrapper.
220-
This avoids stretching Pandas DataFrames. */
238+
/*
239+
Make only Quarto/markdown tables fill the content width.
240+
Pandas DataFrames use class="dataframe" and will be excluded
241+
so they can scroll horizontally instead.
242+
*/
221243
.quarto-table table:not(.dataframe) {
222244
width: 100%;
223245
}
224246

225247

226-
/* Captions left-aligned, no special background */
248+
/* ============================================================
249+
CAPTIONS
250+
============================================================ */
251+
252+
/* Table captions: left-aligned, no special background */
227253
.quarto-float-tbl .quarto-float-caption,
228254
.quarto-float .quarto-float-caption,
229255
table caption {
@@ -232,14 +258,16 @@ table caption {
232258
display: block !important;
233259
box-sizing: border-box !important;
234260
margin-bottom: 0.5em;
235-
padding: 0.4em 0; /* no background color; just spacing */
261+
padding: 0.4em 0; /* spacing only, no background color */
236262
}
237263

238264

239-
/* --- Figures --- */
265+
/* ============================================================
266+
FIGURES
267+
============================================================ */
240268

241269
.quarto-figure,
242-
.figure, /* your custom .figure block */
270+
.figure, /* custom .figure block */
243271
figure {
244272
display: flex !important;
245273
flex-direction: column !important;
@@ -257,12 +285,15 @@ figure {
257285
margin-right: auto;
258286
}
259287

260-
/* Figure captions: visually left-aligned inside centered figure */
288+
/*
289+
Figure captions:
290+
- left-aligned text inside a horizontally centered figure.
291+
*/
261292
.quarto-figure .figure-caption,
262293
.figure .figure-caption,
263294
figure figcaption {
264295
text-align: left !important;
265-
align-self: flex-start !important; /* keep caption left-aligned inside centered flex container */
296+
align-self: flex-start !important;
266297
}
267298

268299
/* Ensure captions don't overflow when left-aligned in narrow columns */
@@ -279,7 +310,9 @@ figure figcaption {
279310
}
280311

281312

282-
/* --- Columns Layout --- */
313+
/* ============================================================
314+
COLUMNS LAYOUT
315+
============================================================ */
283316

284317
.columns {
285318
display: flex !important;
@@ -296,26 +329,32 @@ figure figcaption {
296329
/* .columns { min-height: 220px; } */
297330

298331

299-
/* ----------------------------------------------------------
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.
304-
-----------------------------------------------------------*/
332+
/* ============================================================
333+
WIDE PANDAS DATAFRAMES: HORIZONTAL SCROLL
334+
============================================================ */
305335

306-
/* Constrain output boxes to content width and allow horizontal scroll */
336+
/*
337+
Constrain output boxes to the page/content width and allow
338+
horizontal scrolling when their contents (e.g., Pandas
339+
DataFrames) are wider than the page.
340+
*/
307341
.cell-output-display {
308342
max-width: 100% !important;
309343
overflow-x: auto !important;
310344
}
311345

312-
/* Pandas DataFrame tables should use intrinsic width, not stretch */
346+
/*
347+
Pandas DataFrame tables (class="dataframe") should:
348+
- Use intrinsic width (no stretching to 100%),
349+
- Be allowed to be wider than their container;
350+
the container scrolls horizontally.
351+
*/
313352
.cell-output-display table.dataframe {
314353
width: auto !important;
315354
max-width: none !important;
316355
}
317356

318-
/* Some variants wrap the dataframe in another div; handle those too */
357+
/* Handle the case where Pandas/Quarto wraps the dataframe in an extra div */
319358
.cell-output-display > div > table.dataframe {
320359
width: auto !important;
321360
max-width: none !important;

0 commit comments

Comments
 (0)