Only show image when user is/isn't on mobile #8218
-
I want to make it so that an image only appears (or more specifically, the image that is shown changes) when the page is or isn't viewed on mobile, similar to how you can make it so one only appears in light/dark mode. How can I achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @MegAmi24, mkdocs-material/src/overrides/home.html Lines 54 to 59 in 2e9bd81 To hide on mobile, the limiter .hide-on-mobile {
display: none;
} References: |
Beta Was this translation helpful? Give feedback.
Hello @MegAmi24,
you'd use extra CSS with a media query.
mkdocs-material/src/overrides/home.html
Lines 54 to 59 in 2e9bd81
To hide on mobile, the limiter
max-width: 45em
should probably be fine.Then add a CSS class to your image with
attr_list
like.hide-on-mobile
And combine this selector with the media query
References: