Version 6 des Flex 2 Layouts erstellt einen vertikalen Hover Dropdown…
Vorbereitungen:
In einem ersten Schritt erstellen wir eine einfache Textdatei und nennen sie “index.html“.
In einem zweiten Schritt erstellen wir den Ordner “01_CSS“ und darin erstellen wir folgende einfache Textdateien…
- 01_zentrale.css
- 02_fundament.css
- 03_body.css
- 04_wrapper.css
- 05_kopfbereich.css
- 06_navibereich.css
- 07_textbereich.css
- 08_artikel.css
Der HTML Quelltext:
Der nachfolgende HTML Quellcode wird in die Datei “index.html“ eingefügt.
<!DOCTYPE html>
<html>
<head>
<title>Webdesign 2024</title>
<link rel="stylesheet" href="01_CSS/01_zentrale.css" type="text/css" />
<meta charset="UTF-8">
<meta name="author" content="Webmaster">
<meta name="description" content="Webdesign">
<meta name="keywords" content="Webdesign">
</head>
<body>
<div id="wrapper"> <!-- Anfang vom wrapper-Bereich -->
<header> <!-- Anfang vom header-Element -->
</header> <!-- Ende vom header-Element -->
<nav> <!-- Anfang vom nav-Element -->
<ul>
<li id="startseite"><a href="index.html">Startseite</a></li>
<li id="archiv"><a href="archiv.html">Archiv</a>
<ul>
<li id="001"><a href="001.html">Seite 001</a></li>
<li id="002"><a href="002.html">Seite 002</a></li>
<li id="003"><a href="003.html">Seite 003</a></li>
<li id="004"><a href="004.html">Seite 004</a></li>
</ul>
</li>
<li id="impressum"><a href="impressum.html">Impressum</a></li>
</ul>
<br /><br />
<article>
<h1>Text des Tages:</h1>
<p>
Text des Artikels...
</p>
</article>
<br />
<article>
<h1>Wetter:</h1>
<p>
Text des Artikels...
</p>
</article>
<br />
<article>
<h1>Aktienkurs:</h1>
<p>
Text des Artikels...
</p>
</article>
<br />
</nav> <!-- Ende vom nav-Element -->
<main> <!-- Anfang vom main-Element dem Hauptbereich der Webseite -->
<article>
<h1>Webdesign 2024:</h1>
<p>
Dies ist der Artikeltext zum Layozr Flex 2 Version 6...
</p>
</article>
<br />
</main> <!-- Ende vom main-Element -->
<footer> <!-- Anfang vom footer-Element -->
</footer> <!-- Ende vom footer-Element -->
</div> <!-- Ende vom wrapper-Bereich -->
</body>
</html>
Der CSS-Code für die Datei “01_zentrale.css“:
@import url(02_fundament.css);
@import url(03_body.css);
@import url(04_wrapper.css);
@import url(05_kopfbereich.css);
@import url(06_navibereich.css);
@import url(07_textbereich.css);
@import url(08_artikel.css);
Der CSS-Code für die Datei “02_fundament.css“:
@media all {
/*
Diese Datei dient nur dem Reset. Padding und margin werden auf null gesetzt.
*/
* {
padding: 0;
margin: 0;
}
html {
height: 101%;
}
} /* Ende von @media nicht löschen*/
Der CSS-Code für die Datei “03_body.css“:
@media all {
/*
Diese Datei dient nur der CSS Gestaltung des body-Bereiches.
*/
body {
background-color: white;
color: black;
}
} /* Ende von @media nicht löschen*/
Der CSS-Code für die Datei “04_wrapper.css“:
@media all {
#wrapper {
margin: 5px;
background-color: white;
color: black;
}
/*
Der "wrapper" dient nur als Schutzumschlag um die Webseite und bekommt hier einen margin (Außenabstand) und eine Hintergrundfarbe.
*/
} /* Ende von @media nicht löschen*/
Der CSS-Code für die Datei “05_kopfbereich.css“:
@media all {
header {
height: 80px;
background-image: url(../cpm-header01.jpg);
background-repeat: no-repeat;
background-color: steelblue;
color: white;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
margin-left: 5px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: black;
border-right-color: black;
border-bottom-color: black;
border-left-color: black;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;
}
} /* Ende von @media nicht löschen*/
Der CSS-Code für die Datei “06_navibereich.css“:
@media all {
nav {
position: absolute;
top: 97px;
left: 5px;
width: 210px;
background-color: steelblue;
color: white;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
margin-left: 5px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: black;
border-right-color: black;
border-bottom-color: black;
border-left-color: black;
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
font-family: Arial;
font-size: smaller;
}
nav li {
display: block;
list-style-type: none;
padding: 3px;
}
nav a:link {
color: black;
background-color: white;
display: block;
text-decoration: none;
padding: 3px;
}
nav a:visited {
color: black;
background-color: white;
display: block;
text-decoration: none;
}
nav a:hover {
background-color: red;
color: black;
display: block;
text-decoration: none;
}
nav a:focus {
color: black;
background-color: white;
display: block;
text-decoration: none;
}
nav a:active {
color: black;
background-color: white;
display: block;
text-decoration: none;
}
/* Ab hier soll jetzt die zweite Ebene der Hover-Dropdown-Navigation gestaltet werden */
nav li ul {
position: absolute;
left: -9999px;
top: -9999px;
}
nav li:hover ul {
left: 10px;
top: auto;
display: block;
width: 210px;
height: auto;
}
} /* Ende von @media nicht löschen*/
Der CSS-Code für die Datei “07_textbereich.css“:
@media all {
/*
CSS Gestaltung für den Textbereich
*/
main {
background-color: steelblue;
color: white;
margin-top: 3px;
margin-right: 5px;
margin-bottom:5px;
margin-left: 241px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: black;
border-right-color: black;
border-bottom-color: black;
border-left-color: black;
padding-top: 20px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 20px;
font-family: Arial;
font-size: smaller;
}
main a:link {
color: white;
background-color: steelblue;
text-decoration: underline;
}
main a:visited {
color: white;
background-color: steelblue;
text-decoration: underline;
}
main a:hover {
color: black;
background-color: white;
text-decoration: underline;
}
main a:focus {
color: white;
background-color: steelblue;
text-decoration: underline;
}
main a:active {
color: white;
background-color: steelblue;
text-decoration: underline;
}
} /* Ende von @media nicht löschen*/
Der CSS-Code für die Datei “08_artikel.css“
@media all {
article {
overflow: hidden;
color: black;
background-color: lightsteelblue; /* Grundeinstellung = lightsteelblue */
padding: 5px;
border-style: solid;
border-color: black;
border-width: 1px;
}
.clearingtext {
clear: both;
background-color: lightsteelblue;
}
.bildlinks {
float: left;
margin-top: 5px;
margin-right: 15px;
margin-bottom: 5px;
margin-left: 0px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid; /* dashed ergibt eine gestrichelte Rahmenlinie*/
border-left-style: solid;
border-top-color: black;
border-right-color: black;
border-bottom-color: black;
border-left-color: black;
}
.bildrechts {
float: right;
margin-top: 5px;
margin-left: 15px;
margin-bottom: 5px;
border-style: solid;
border-width: 1px;
}
} /* Ende von @media nicht löschen*/