如何将元素设置为在 Tailwind 中的中等屏幕及以下屏幕上显示?
How to set an element to show on medium screen and below in Tailwind?
我有一个 div,其中 class 的 hidden md:block
包含 heroicon 中的这个元素:
<MenuIcon class="ml-1 mr-2 h-5 w-5 text-gray-500"/>
.
目前,div 元素仅在屏幕尺寸为 md
时显示,但我想在 md
和 时显示下面,我该怎么做呢?
Tailwind 断点优先移动,因此它们向上移动。一开始一切都是可见的。
你只需要隐藏元素。一些尺码及以上:
sm -> md - > lg -> xl -> 2xl
class="lg:hidden"
将隐藏 lg 及以上的元素 - lg, xl, 2xl
有关该主题的更多信息,请参阅:Responsive design in Tailwind
我相信你是反过来做的。
基本上=>
https://tailwindcss.com/docs/responsive-design
Where this approach surprises people most often is that to style
something for mobile, you need to use the unprefixed version of a
utility, not the sm: prefixed version. Don’t think of sm: as meaning
“on small screens”, think of it as “at the small breakpoint“.
所以你必须在你的 类 中做 class="block lg:hidden"
才能像你描述的那样工作:)
我有一个 div,其中 class 的 hidden md:block
包含 heroicon 中的这个元素:
<MenuIcon class="ml-1 mr-2 h-5 w-5 text-gray-500"/>
.
目前,div 元素仅在屏幕尺寸为 md
时显示,但我想在 md
和 时显示下面,我该怎么做呢?
Tailwind 断点优先移动,因此它们向上移动。一开始一切都是可见的。
你只需要隐藏元素。一些尺码及以上:
sm -> md - > lg -> xl -> 2xl
class="lg:hidden"
将隐藏 lg 及以上的元素 - lg, xl, 2xl
有关该主题的更多信息,请参阅:Responsive design in Tailwind
我相信你是反过来做的。
基本上=> https://tailwindcss.com/docs/responsive-design
Where this approach surprises people most often is that to style something for mobile, you need to use the unprefixed version of a utility, not the sm: prefixed version. Don’t think of sm: as meaning “on small screens”, think of it as “at the small breakpoint“.
所以你必须在你的 类 中做 class="block lg:hidden"
才能像你描述的那样工作:)