diff --git a/Shared/Article Rendering/core.css b/Shared/Article Rendering/core.css index 80ef06314..a8c55443a 100644 --- a/Shared/Article Rendering/core.css +++ b/Shared/Article Rendering/core.css @@ -6,6 +6,14 @@ html { scrollbar-gutter: stable; } +/* Keep absolutely positioned feed content from escaping the body and overlapping the title. + (.article-body is the Biblioteca theme's name for .articleBody.) */ + +.articleBody, +.article-body { + position: relative; +} + /* This is the activity indicator (currently iOS only) that is used while image zooming */ .activityIndicatorWrap { diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index 48eafcd34..f43399379 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -31,7 +31,10 @@ function constrainBodyRelativeIframes() { let iframes = document.getElementsByTagName("iframe"); for (iframe of iframes) { - if (iframe.offsetParent === document.body) { + // The article body container is positioned, so it — not document.body — + // is the offsetParent for iframes with no positioned ancestor in the content. + const offsetParent = iframe.offsetParent; + if (offsetParent === document.body || (offsetParent && (offsetParent.classList.contains("articleBody") || offsetParent.classList.contains("article-body")))) { let heightAttribute = iframe.style.height; if (/%|vw|vh$/i.test(heightAttribute)) {