Replies: 4 comments
-
Yeah tricky one, I think this is just one of those weird quirks you run into because of this stupid hack we've all had to use forever to render screen-reader-only text. In my testing wrapping the <div class="overflow-y-scroll border-red-500 border-4 w-1/6 h-80">
<div class="bg-indigo-500 h-40"></div>
<div class="bg-pink-500 h-40"></div>
<div class="bg-indigo-500 h-40"></div>
<div class="bg-pink-500 h-40"></div>
<div class="bg-indigo-500 h-40"></div>
<div class="bg-pink-500 h-40"></div>
<div class="bg-indigo-500 h-40"></div>
<div class="bg-pink-500 h-40"></div>
<div class="bg-indigo-500 h-40"></div>
<div class="bg-pink-500 h-40"></div>
<span class="relative">
<span class="sr-only">Settings</span>
</span>
</div> I'm going to move this to discussions just because I don't think we can really change the implementation of |
Beta Was this translation helpful? Give feedback.
-
Could you perhaps add this to the docs? Just spent 30 minutes figuring out what was breaking my overflow. It was, like you mentioned, an sr-only in a table. Your workaround worked, so thanks for that. |
Beta Was this translation helpful? Give feedback.
-
We should include a notice and this workaround in the docs on https://tailwindcss.com/docs/screen-readers. The sidebar component template from tailwindui.com uses a Adding a note and this fix to the guide would help save time for other developers. |
Beta Was this translation helpful? Give feedback.
-
The scroll issue is due the absolute position style in the sr-only element. The element is hanging around as an invisible block outside the viewport which is then causing the scroll. Another workaround is to use fixed position instead without any extra markup like: <span class="sr-only fixed">Settings</span> |
Beta Was this translation helpful? Give feedback.
-
What version of Tailwind CSS are you using?
latest from: https://cdn.tailwindcss.com
What build tool (or framework if it abstracts the build tool) are you using?
none
What version of Node.js are you using?
none
What browser are you using?
Chrome
What operating system are you using?
Linux
Reproduction URL
https://codepen.io/pladaria/pen/KKJyXjR
Describe your issue
sr-only
inside a div with overflow produces unwanted scroll in the document.After removing the
sr-only
class the document scroll disappears:A workaround is to add a "large enough" negative positioning to the element, like
left: -100000px; right: -100000px
. Not sure whether this has a11y implications.This could be a Chromium bug. Not reproduced in Firefox
Beta Was this translation helpful? Give feedback.
All reactions