Wiederholungs-Challenge
Teil des Abschnitts Praktisches Frontend der HTML-Journey von Coddy. Lektion 11 von 35.
Aufgabe
EinfachDir wird eine HTML-Seite für ein Benutzerprofil gegeben. Deine Aufgabe ist es, Prinzipien des Mobile-First-Designs anzuwenden, damit die Seite vollständig responsiv ist. Befolge diese Anweisungen:
1. Mobile-First-Navigation
- Zeige auf größeren Bildschirmen die Navigationsliste an und blende die Menütaste aus.
2. Mobile-First-Typografie
- Erstelle eine CSS-Variable
--body-font-size: 16pxund wende sie auf den Body an. Dies ist die grundlegende Schriftgröße für kleine Bildschirme.
3. Mobile-First-Bilder
- Verwende das
<picture>-Tag, um unterschiedliche Bildgrößen für Mobilgeräte und größere Bildschirme bereitzustellen. - Verwende das
<source>-Tag mitsrcset, das auf ein größeres Bild verweist, zum Beispiel:https://upload.wikimedia.org/wikipedia/commons/1/1f/Woman_1.jpg. - Füge
media="(min-width: 768px)"hinzu, damit es auf größeren Bildschirmen angewendet wird. - Stelle sicher, dass sich das Profilbild abhängig von der Bildschirmbreite korrekt skaliert.
4. Mobile-First-Formulare
- Setze die Breite aller Eingabefelder und der Senden-Schaltfläche auf
100%, damit sie die gesamte Breite einnehmen und leicht angetippt werden können.
Die Seite sollte sowohl auf mobilen als auch auf Desktop-Bildschirmen übersichtlich, lesbar und benutzerfreundlich aussehen. Wende Abstände, Ausrichtung und responsive Größenanpassungen an, damit alles ausgewogen wirkt.
Probier es selbst
<!DOCTYPE html>
<html>
<head>
<title>Mobile-First Profile</title>
<style>
:root {
--primary-font: Arial, sans-serif;
--heading-font: 'Helvetica', sans-serif;
--h1-size: 2rem;
--h2-size: 1.5rem;
--primary-color: #4a90e2;
--secondary-color: #f0f4f8;
}
body {
font-family: var(--primary-font);
margin: 0;
padding: 20px;
background-color: var(--secondary-color);
}
h1 {
font-family: var(--heading-font);
font-size: var(--h1-size);
color: var(--primary-color);
margin-bottom: 5px;
}
h2 {
font-family: var(--heading-font);
font-size: var(--h2-size);
color: #333;
margin-top: 0;
}
nav {
margin-bottom: 20px;
}
.menu-button {
display: block;
padding: 10px 15px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-bottom: 10px;
}
.nav-list {
display: none;
list-style: none;
padding: 0;
margin: 0;
}
.nav-list li {
margin-bottom: 10px;
}
.nav-list li a {
text-decoration: none;
color: var(--primary-color);
}
.profile-img {
width: 100%;
max-width: 250px;
border-radius: 50%;
margin-bottom: 20px;
display: block;
}
section p {
line-height: 1.6;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
gap: 10px;
}
input, textarea, button {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}
button {
background-color: var(--primary-color);
color: white;
cursor: pointer;
}
/* Media queries for larger screens */
@media (min-width: 768px) {
.nav-list {
gap: 20px;
}
.nav-list li {
margin-bottom: 0;
}
form {
max-width: 500px;
}
}
</style>
</head>
<body>
<nav>
<button class="menu-button">Menu</button>
<ul class="nav-list">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<header>
<h1>Jane Doe</h1>
<h2>Web Developer & Designer</h2>
</header>
<section>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Woman_1.jpg/250px-Woman_1.jpg" alt="Profile Image" class="profile-img">
</section>
<section>
<p>Welcome to my profile! I specialize in creating mobile-first, responsive websites that look great on any device. My focus is on performance, accessibility, and clean design.</p>
</section>
<section>
<form>
<input type="text" placeholder="Your Name">
<input type="email" placeholder="Your Email">
<textarea placeholder="Your Message"></textarea>
<button type="submit">Send Message</button>
</form>
</section>
</body>
</html>
Alle Lektionen in Praktisches Frontend
1Variablen
VariablenCSS-Variablen verwendenVariablen für Design-TokensLokale VariablenRückblick-Herausforderung7Abschließende Herausforderungen
ProfilkarteSchokoladengalerie-RasterSieben WeltwunderNeue sieben Weltwunder2Mobile-First-Strategie
Was „Mobile-First“ bedeutetMobile-First-TypografieMobile-First-NavigationMobile-First-BilderMobile-First-FormulareWiederholungs-ChallengeÜbe selbstständig: Web-Playground