yarsvent
yarsvent

Reputation: 1

Is there a way to position a dropdown menu under the selected button in the navigation menu?

Beginner in CSS, recently I made a navigation menu, and now I want to add a dropdown menu to one of the buttons. However, it seems that the dropdown menu is misaligned and I'm not sure what I can do. I want for it to be under the button I selected. The navigation menu The dropdown menu (misaligned)

.neu-button {
  border: none;
  background-color: #f0f0f3; /* 1 white */
  height:77px;
  width:280px;
  filter: drop-shadow(-2px -2px 7px rgba(255,255,255,0.75)) drop-shadow(4px 4px 15px rgba(0,0,0,0.125));
  border-radius: 16px;
  text-align: center;
  font-size: 1.5em;
  color: #C590EF; /* 400 violet */
  transition: 0.3s;
  margin-left: 10px;
  user-select: none;
  overflow: hidden;
}
.neu-button:hover {
  filter: drop-shadow(-1px -1px 5px rgba(255,255,255,1)) drop-shadow(2px 2px 10px rgba(0,0,0,0.5));
}
.neu-navmenu {
  display: block;
  justify-content: center;
  align-items: center;
  list-style-type: none;
  margin: 0;
  padding: 0;
  text-align: center;
  position: relative;
}
.neu-navmenu li {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin: 10px;
  width: 170px;
}
.neu-button + .dropdown {
  display: none;
  position: absolute;
}
.neu-button:hover + .dropdown {
  display: block;
}
<ul class="neu-navmenu">
  <li class="neu-button">Главная</li>
  <li class="neu-button">Проекты</li>
  <li class="neu-button dropdown">DanganAwful</li>
  <li class="neu-button">Неоморфизм</li>
  <li class="neu-button">Стилизация</li>
  <li class="neu-button">CSS</li>
</ul>

I attempted to make the navigation menu container relative, but it did not work. I managed to get it working with JavaScript and absolute positioning, but the goal is to make it with pure CSS.

Upvotes: 0

Views: 34

Answers (0)

Related Questions