<body>
<header> ... </header>
<div class="desktop"> Hello World! </div>
<footer> ... </footer>
</body>
I used to always render the desktop view using the meta tag, but I need the header and footer responsive and need the div element with class ‘desktop’ to be rendered in desktop view.
Is it possible without CSS ?
2
Answers
From my knowledge this is not possible with native React, but you might want to check out the react-responsive package.
React-responsive allows you to conditionally render components based on screen width.
Might be possible without CSS, but with Media Queries, this could be as simple as hiding the
<header>
and<footer>
elements when the devices width is bigger than, let’s say, 800px. This is a very simple thing to do in CSS, and you should be able to learn it quickly.Something like this (play around with your viewport a little to see the effects):
As you can see,
<header>
and<footer>
get shown only when the device/ viewport width gets under600px
, and are hidden when the width is above that. You would probably exchange(min-width: 600px)
for a value that actually targets the desktop pixel width you aim for.If your development environment does not allow or makes it unpossible to use CSS, then you should fix that first, since most modern applications & websites simply require some CSS – like this problem here.