Beispiel:CSS-flyout-details.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html lang="de">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flyout mit details</title>
<style>
:root {
	--blue-darker: hsl(200 50% 15%);
	--blue: hsl(201 50% 40%);;
	--blue2: hsl(201 50% 75%);
	--red: hsl(13 96% 40%);
	--yellow: hsl(44 75% 50%);
	--bgcolor: var(--blue-darker);
}

header {
  position: relative;
}
header h1 {
  margin-bottom: 0;
}
nav summary {
  list-style-type: "☰";
  font-size: 2rem;
  position: absolute;
  top: 0;
  right: 0;
  cursor:pointer;
}
nav summary:hover {
  font-size:2.2em;
  text-shadow: 2px 2px 5px white;
}
nav summary span {
  font-size: 0;
}
nav [open] summary {
  list-style-type: "✖";
  color: var(--red);
}
nav details {
  text-align: right;
}
nav ul {
  margin-top: 0;
  margin-right: 2em;
  display: inline-block;
}

body {
 background: var(--bgcolor);
 font-family: 'Arial', sans-serif;
 padding: 1em;
 max-width: 40em;
 color: white;
}
a {
  color: var(--blue2);
}

a:hover,
a:focus {
	color: var(--yellow);
}

</style>
<script>
</script>
</head>
<body>
<header>
<header>
  <h1>
    <a href="#">Logo</a>
  </h1>
  <nav role="navigation">
    <details>
    <summary><span>Menü</span></summary>
    <ul id="menu">
      <li><a aria-current="page">Home</a></li>
      <li><a href="#">Seite 2</a></li>
      <li><a href="#">Seite 3</a></li>
      <li><a href="#">Seite 4</a></li>
      <li><a href="#">Kontakt</a></li>
    </ul>
    </details>
  </nav>
</header>

<main>
<h2>Flyout-Menü mit toggle-Button</h2>
<p>Diese Variante kommt ohne JavaScript und ohne button aus.</p>
<p>Stattdessen bietet das details-Element eine <em>collapsible</em> Box.</p>

</main>
</body>
</html>