1
I have a question and I think other people might have that same question too...
Let’s go: I have a website, with header edited to appear on computer screens (resolutions bigger than tablets) but I would like when accessing the site by a mobile phone or tablet the header change.
Example: I have a Logo1280x720.PNG and would like Logo320x70.PNG to appear when accessed by mobile version.
I know how to hide a div in lower resolution, but and to display a div in mobile version as it does?
Obs: The site itself is already responsive
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0" />
In short: I NEED A DIV SUMA AND ANOTHER APPEARS IN MOBILE AND A DIV SUMA AND ANOTHER APPEARS IN DESKTOP VERSION
Edit@2: Put it like this in HTML:
<div class="logopngdesktop"><h1 id="logo"><a href="#">Recarga de Toner e Cartuchos, Manutenção de Impressoras</a></h1></div>
<div class="logopngmobile"><h1 id="logo"><a href="#">Recarga de Toner e Cartuchos, Manutenção de Impressoras</a></h1></div>
And so in CSS:
@media only screen and (max-width: 400px) { .logopngdesktop{ display: none !important; } } @media only screen and (min-width: 601px) { .logopngmobile { display: none !important; } }
It disappears in the Mobile version but the part where it was supposed to appear in the mobile version does not work. What can I be missing?
SOLUTION:
Problem solved, I want to leave the resolution here for all who have the same problem:
Html:
<!-- aparecer no desktop -->
<div class="mobile-hide"><h1 id="logo"><a href="#">Recarga de Toner e Cartuchos, Manutenção de Impressoras</a></h1></div>
<!-- aparecer no mobile -->
<div class="mobile"><div class="desktop-hide"><h1 class="logomobile"><a href="#">Recarga de Toner e Cartuchos, Manutenção de Impressoras</a></h1></div></div>
Css:
@media only screen and (max-width: 400px) {
.mobile-hide{ display: none !important; }
}
@media only screen and (max-width: 400px) {
.mobile{ display: inline !important; }
}
@media only screen and (min-width: 500px) {
.desktop-hide{ display: none !important; }
}
I thank everyone who tried to help!
It worked though, there’s no way I can do it like this: div1 appears on mobile some on desktop > div2 appears on desktop and some on mobile ? I’m sorry, I’m a layman...
– João Victor Gomes Moreira
@Victorgomes, media querys are based on screen size. Formerly, I THINK, there was a parameter that identified the device, but it was discontinued. To identify the device the user is using, you will need to resort to other tools. Mauritius' reply seems to answer that question well.
– Clayderson Ferreira
the problem is not knowing the device, may be by resolution, but how I would make a div appear, and disappear and another disappear and appear ?
– João Victor Gomes Moreira
What is the resolution of mobile? Let’s take as base 320px. @media screen and (min-width: 320px) ' #div1 { display: inline; } #div2 { display: None; } } and outside the media query you define: #div1 { display: None; } #div2 { display: inline; }
– Clayderson Ferreira
Based on the principle of specificity applied to the CSS that says rules that are more specific have higher priority, you will get what you want using the above code and, making the appropriate changes to your project, of course.
– Clayderson Ferreira
Thank you, solved kk mt thank you even
– João Victor Gomes Moreira