Ich habe bereits eine Webseite entworfen, bevor ich etwas über Mobile-First-Design gelernt habe.Re-design für Mobile First Design
Beim Erstellen eines responsiven Designs habe ich 3 Klassen erstellt: .mobile, .tablet, .desktop.
Ich rufe alle diese Klassen in meiner Navigationsleiste, aber anscheinend nicht zu meiner mobilen Abfrage beim ersten Entwurf für mobile aufrufen (ich verstehe, warum). Jedes Mal, wenn ich meine .mobile-Klasse entferne, werden die mobilen Informationen angezeigt. Wenn ich das Fenster auf ein größeres Fenster umstelle, bleiben die mobilen Informationen erhalten und die Tablet-/Desktop-Informationen werden hinzugefügt. Wie würde ich das richtig gestalten? Dies ist mein Hauptinhalt in Arbeitsform beim Ändern der Fenstergröße.
/*Mobile Query*/
@media only screen and (max-width:480px) {
.mobile {
display: block;
}
.desktop,
.tablet {
display: none;
}
}
/*Tablet Query*/
@media only screen and (min-width: 481px) and (max-width:768px) {
.tablet {
display: block;
}
.mobile,
.desktop {
display: none;
}
}
/*Desktop Query*/
@media only screen and (min-width: 769px) {
.desktop {
display: block;
}
.mobile,
.tablet {
display: none;
}
}
<h2 class="mobile">About Me</h2>
<p class="mobile">I will not disappoint and I will perform to the best of my ability.</p>
<h2 class="tablet">About Me</h2>
<p class="tablet"> I am somebody who tries their best not to disappoint. I fear that my disappointment will reflect poorly upon myself and people who are close to me. This is something that motivates me to work hard and not to complain. Currently, I work part-time at a
grocery store, run a side business, and go to school more than full time.</p>
</article>
<h2 class="desktop">Strengths</h2>
<p class="desktop">One of my strengths include being very talented at learning or developing new ways to complete objectives. I always enjoy learning about different perspectives, and I believe it is needed to be successful. Another one of my strengths is the ability to
see an error and immediately want to correct it rather than ignoring it and leaving somebody else to fix it. I am driven to be the best at anything I do while wanting to help other people and make their jobs easier.</p>
Aber Ihre drei Blöcke sind die gleichen html ... Ich denke, Sie bekommen nicht den Punkt der Medienabfragen. Oder ist das nur ein schreckliches Beispiel? Der Punkt ist, das CSS des gleichen Elements bei verschiedenen Bildschirmgrößen zu ändern. Es gibt nur wenige Fälle, in denen Sie bestimmte Blöcke zum Ein-/Ausblenden benötigen. – DaniP
Warum würden Sie den gesamten Inhalt in einer beliebigen Ansichtsfenstergröße ausblenden? Scheint ziemlich wertvoll für den Benutzer. Du hast keine kilometerlangen Inhalte. – hungerstar
Es ist nicht ALL die Informationen für das Desktop-Ansichtsfenster –