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>
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: #c82f04;
}
nav details {
  text-align: right;
}
nav ul {
  margin-top: 0;
  margin-right: 2em;
  display: inline-block;
}

:root {
	--blue: #337599;
	--blue4: #adc8d6;
	--black: #113;
	--yellow: #dfac20;
}

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

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>