From 0d2ef223c4ec9e9f0cd8e865c714f8953a8fb733 Mon Sep 17 00:00:00 2001 From: randogoth Date: Wed, 3 May 2023 23:24:05 +0300 Subject: [PATCH] better display --- web/mc-pelican/static/local.css | 2 +- web/mc-pelican/static/script.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/mc-pelican/static/local.css b/web/mc-pelican/static/local.css index e1b97cd..22eaa88 100644 --- a/web/mc-pelican/static/local.css +++ b/web/mc-pelican/static/local.css @@ -227,7 +227,7 @@ abbr { display: block; background-attachment: fixed; background-position: center; - background-size: contain; + background-size: cover; } iframe { diff --git a/web/mc-pelican/static/script.js b/web/mc-pelican/static/script.js index b35890e..9d41a57 100644 --- a/web/mc-pelican/static/script.js +++ b/web/mc-pelican/static/script.js @@ -12,7 +12,12 @@ for (let i = 0; i < paras.length; i++) { var imageSrc = paras[i].style.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2').split(',')[0]; var image = new Image(); image.src = imageSrc; - paras[i].setAttribute("offset", paras[i].getBoundingClientRect().bottom - image.height * 0.5); + if ( screen.width > screen.height ) { + paras[i].setAttribute("offset", paras[i].getBoundingClientRect().bottom - image.height * 0.5); + } else { + paras[i].parentNode.insertBefore(image, paras[i].nextSibling); + paras[i].style.display = 'none'; + } } window.addEventListener('scroll', () => { let { scrollY } = window;