Target Mobile Landscape viewport #2397
Replies: 6 comments 1 reply
-
I think you'll want to look into Media Queries' Orientation. And then check out Custom Media Queries in Tailwind, which, ironically, is showing one how to target portrait orientation. |
Beta Was this translation helpful? Give feedback.
-
Thanks @Natetronn, I will check them out 👍 |
Beta Was this translation helpful? Give feedback.
-
Following said instructions, I created these custom screen sizes for You can double down on the media/breakpoints using stacked prefixes, eg: theme: {
extend: {
screens: {
'tall': {
'raw': `only screen and (max-height: 960px) and (max-width: 480px)`
},
'wide': {
'raw': `only screen and (max-height: 480px) and (max-width: 960px)`
},
'portrait': {
'raw': '(orientation: portrait)'
},
'landscape': {
'raw': '(orientation: landscape)'
}}}}, And tested them with this: <div class="invisible badge badge-primary xl:visible">XL</div>
<div class="invisible badge badge-primary 2xl:visible">2XL</div>
<div class="invisible badge badge-primary md:visible">MD</div>
<div class="invisible badge badge-primary sm:visible">SM</div>
<div class="invisible badge badge-primary lg:visible">LG</div>
<div class="invisible badge badge-primary tall:visible">TALL</div>
<div class="invisible badge badge-primary wide:visible">WIDE</div>
<div class="invisible badge badge-primary portrait:visible">PORTRAIT</div>
<div class="invisible badge badge-primary landscape:visible">LANDSCAPE</div> My iPhone 10XS shows as My 1920x1080 standard desktop (Chrome) shows |
Beta Was this translation helpful? Give feedback.
-
What's the nicest way to target a certain viewport but only in landscape? Do I have to create that specific media query in the config?.. or can it be combined? E.g |
Beta Was this translation helpful? Give feedback.
-
as of tailwind 3.0 you can use
|
Beta Was this translation helpful? Give feedback.
-
Perhaps solve this by adding a custom breakpoint like below. The use of (I have added an additional s to landscapeS in the below to make a custom additional breakpoint. You can probably also amend the existing one but I do not know how yet.)
|
Beta Was this translation helpful? Give feedback.
-
Anyone know the best way to deal with Mobile Landscape viewport in Tailwind eg. how to target it specifically?
Beta Was this translation helpful? Give feedback.
All reactions