Skip to content

Fix uncontained CSS float on book page causing catalog download tools to overflow content boundaries #13090

Description

@RsbhThakur

Problem

On the book edition/view pages, the "Download catalog record" bar (RDF / JSON / OPDS | Wikipedia citation) overflows its parent container #contentBody. This occurs because the bar is styled using .pageHistory__tools which has float: right, but the parent container does not clear the floated element. This causes the element to hang outside the visual border of the white container area, bleeding into the gray background/margin area.

We have explored and verified two clean approaches to resolve this, both of which render beautifully and are fully responsive:

Approach 1: Clearfix with Semantic Margin-Bottom offset (Recommended)

Since the lib/exports template is floated, we can clear the float in the parent template openlibrary/templates/type/edition/view.html immediately after rendering the tools. To prevent the clearfix from creating too much empty space due to container padding, we use a negative margin calculated semantically from the container's padding custom variable:

$:render_template("lib/exports", page)
<div class="clearfix" style="margin-bottom: calc(-1 * var(--contentBody-padding));"></div>
Image

Approach 2: Redefining Floated Tool Padding

Alternatively, we can adjust the top padding of the floated tools class .pageHistory__tools inside static/css/components/page-history.css from 8px to 3px. This shifts the element slightly up so that it aligns nicely within the parent container's padding:

.pageHistory__tools {
  font-size: 0.7em;
  float: right;
  padding-top: 3px;
}
Image

Both of these approaches successfully contain the element within the white boundaries of #contentBody across all standard viewport widths (desktop, tablet, and mobile), avoiding any container overflow or text-clipping.

  • Relevant URL: Any book/edition page, e.g. https://openlibrary.org/books/OL24620876M/Responsive_Web_Design
  • Screenshots:
Image

Reproducing the bug

  1. Go to any book/edition detail page (e.g., https://openlibrary.org/books/OL24620876M/Responsive_Web_Design).
  2. Scroll to the very bottom of the book's details container.
  3. Observe the "Download catalog record: RDF / JSON / OPDS | Wikipedia citation" line.
  • Expected behavior: The download tools bar should be cleanly contained within the main content body's background and padding.
  • Actual behavior: The text overflows past the bottom padding of the content body container, hanging outside the boundary line.

Context

  • Browser (Chrome, Safari, Firefox, etc): Chrome
  • OS (Windows, Mac, etc): Windows
  • Logged in (Y/N): Y
  • Environment (prod, dev, local): all

Breakdown

Implementation Details (for maintainers)

Requirements Checklist

  • [ ]

Related files

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

Metadata

Metadata

Assignees

Labels

Lead: @lokeshIssues pertaining to front-end design system [css, js, components]Priority: 3Issues that we can consider at our leisure. [managed]Type: BugSomething isn't working. [managed]

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions