Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dropdown menu html + css without JavaScript

Hello could someone please tell me why my menu does not go from page to page.
Dropdown works but when I click it doesn’t go to the subpage. Anticipating the question, I don’t want to use JavaScript. Buttons without dropdown menu works. If this cannot be fixed, could someone sent me a menu in similar style without JavaScript.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #333;
}

hr {
  border-top: 2px dashed white;
  border-bottom: none;
}

a {
  text-decoration: none;
  color: black;
}

.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.navbar {
  height: 6vh;
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 60%;
  margin: auto;
}

.dropdown {
  position: relative;
}

.dropdown ul {
  position: absolute;
  background: #bebebe;
  margin-top: 10px;
  width: 200px;
  height: 200px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-direction: column;
  list-style: none;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.6s ease;
  left: 0px;
}

.dropdown li {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.dropdown li:hover {
  background-color: darkslategray;
}

.navbar button,
.deco {
  background: none;
  border: none;
  color: black;
  text-decoration: none;
  font-size: 18px;
  cursor: pointer;
}

.navbar button:hover,
.deco:hover {
  color: darkslategray;
}

.dropdown button:focus+ul {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0px);
}

.top {
  text-decoration: none;
  background: yellow;
  border: none;
  color: black;
  font-size: 48px;
  cursor: pointer;
  border-radius: 5px;
  width: 45px;
  height: 45px;
  align-items: center;
  right: 0;
  bottom: 0;
  position: fixed;
}

.autor {
  color: #bebebe;
  font-size: 16px;
}

.printButton {
  border: none;
  font-size: 18px;
  border-radius: 5px;
  width: 80px;
  height: 20px;
  cursor: pointer;
  color: black;
  background: darkslategray;
}

@media print {
  .noPrint {
    display: none;
  }
}
<header class="noPrint">
  <a href="index.html"><img src="https://via.placeholder.com/80" alt="Logo strony" class="center"></a>
  <div class="navbar">
    <button><a href="index.html" class="deco">Główna</a></button>
    <div class="dropdown">
      <button>Ciasta</button>
      <ul>
        <li><a href="biszkopt.html">Biszkopt</a></li>
        <li><a href="beza.html">Beza</a></li>
        <li><a href="makowiec.html">Makowiec</a></li>
      </ul>
    </div>
    <div class="dropdown">
      <button>Pieczywo</button>
      <ul>
        <li><a href="chleb.html">Chleb</a></li>
        <li><a href="bulki.html">Bułki</a></li>
        <li><a href="bulkiNaSlodko.html">Bułki na słodko</a></li>
      </ul>
    </div>
    <button><a href="informacje.html" class="deco">Informacje</a></button>
  </div>
</header>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m not sure what you want but is it like this?

.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown > .dropdown-text {
    padding: 10px 20px;
    position: relative;
}
.dropdown > input {
    top: 0;
    opacity: 0;
    display: block;
    padding: 0;
    margin: 0;
    position: absolute;
    height: 100%;
    width: 100%;
    cursor: pointer;
}
.dropdown > input:checked ~ .dropdown-container {
    transform: scaleY(1);
}
.dropdown > .dropdown-container {
    display:block;
    position: absolute;
    background-color: #ffffff;
    transform: scaleY(0);
    left:0;
    width: 250px;
    top: 38px;
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.3);
}
.dropdown > .dropdown-container > a {
    display: block;
    position: relative;
    text-decoration: none;
    padding: 10px;
    background-color: #ffffff;
    color: #000000;
}
<div class="dropdown">
    <div class="dropdown-text">THIS IS A DROPDOWN</div>
    <input type="checkbox">
    <div class="dropdown-container">
        <a href="/link1">Item 1</a>
        <a href="/link2">Item 2</a>
        <a href="/link3">Item 3</a>
    </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading