Home > database >  Why is this section is acting very wierd when hovered?
Why is this section is acting very wierd when hovered?

Time:02-23

This is a side-navbar file which I made by watching a youtube video and I tweaked some things in it and its working fine but there's a little problem. Whenever I hover on the profile info box which is on bottom it starts to dance. Why?

let arrow = document.querySelectorAll(".arrow");
for (var i = 0; i < arrow.length; i  ) {
  arrow[i].addEventListener("click", (e) => {
    let arrowParent = e.target.parentElement.parentElement; //selecting main parent of arrow
    arrowParent.classList.toggle("showMenu");
  });
}

let sidebar = document.querySelector(".sidebar");
let sidebarBtn = document.querySelector(".bx-menu");
console.log(sidebarBtn);
sidebarBtn.addEventListener("click", () => {
  sidebar.classList.toggle("close");
});
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 260px;
  z-index: 100;
  transition: all 0.5s ease;
  backdrop-filter: blur(25px);
  box-shadow: 10px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar.close {
  width: 78px;
}

.sidebar .logo-details {
  height: 60px;
  width: 100%;
  display: flex;
  align-items: center;
}

.sidebar .logo-details i {
  font-size: 30px;
  color: #444444;
  height: 50px;
  min-width: 78px;
  text-align: center;
  line-height: 50px;
}

.sidebar .logo-details .logo_name {
  font-size: 22px;
  color: #444444;
  font-weight: 600;
  transition: 0.3s ease;
  transition-delay: 0.1s;
}

.sidebar.close .logo-details .logo_name {
  transition-delay: 0s;
  opacity: 0;
  pointer-events: none;
}

.sidebar .nav-links {
  height: 100%;
  padding: 30px 0 150px 0;
  overflow: auto;
}

.sidebar.close .nav-links {
  overflow: visible;
}

.sidebar .nav-links::-webkit-scrollbar {
  display: none;
}

.sidebar .nav-links li {
  position: relative;
  list-style: none;
  transition: all 0.4s ease;
}

.sidebar .nav-links li:hover {
  backdrop-filter: blur(40px);
  box-shadow: 10px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar .nav-links li .iocn-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar.close .nav-links li .iocn-link {
  display: block
}

.sidebar .nav-links li i {
  height: 50px;
  min-width: 78px;
  text-align: center;
  line-height: 50px;
  color: #444444;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sidebar .nav-links li.showMenu i.arrow {
  transform: rotate(-180deg);
}

.sidebar.close .nav-links i.arrow {
  display: none;
}

.sidebar .nav-links li a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.sidebar .nav-links li a .link_name {
  font-size: 18px;
  font-weight: 400;
  color: #444444;
  transition: all 0.4s ease;
}

.sidebar.close .nav-links li a .link_name {
  opacity: 0;
  pointer-events: none;
}

.sidebar .nav-links li .sub-menu {
  padding: 6px 6px 14px 80px;
  margin-top: -10px;
  display: none;
  backdrop-filter: blur(25px);
  box-shadow: 10px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar .nav-links li.showMenu .sub-menu {
  display: block;
}

.sidebar .nav-links li .sub-menu a {
  color: #444444;
  font-size: 15px;
  padding: 5px 0;
  white-space: nowrap;
  opacity: 0.6;
  transition: all 0.3s ease;
}

.sidebar .nav-links li .sub-menu a:hover {
  opacity: 1;
}

.sidebar.close .nav-links li .sub-menu {
  position: absolute;
  left: 100%;
  top: -10px;
  margin-top: 0;
  padding: 10px 20px;
  border-radius: 0 6px 6px 0;
  opacity: 0;
  display: block;
  pointer-events: none;
  transition: 0s;
}

.sidebar.close .nav-links li:hover .sub-menu {
  top: 0;
  opacity: 1;
  pointer-events: auto;
  transition: all 0.4s ease;
}

.sidebar .nav-links li .sub-menu .link_name {
  display: none;
}

.sidebar.close .nav-links li .sub-menu .link_name {
  font-size: 18px;
  opacity: 1;
  display: block;
}

.sidebar .nav-links li .sub-menu.blank {
  opacity: 1;
  pointer-events: auto;
  padding: 3px 20px 6px 16px;
  opacity: 0;
  pointer-events: none;
}

.sidebar .nav-links li:hover .sub-menu.blank {
  top: 50%;
  transform: translateY(-50%);
}

.sidebar .profile-details {
  position: fixed;
  bottom: 0;
  width: 260px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  transition: all 0.5s ease;
  backdrop-filter: blur(60px);
  box-shadow: 10px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar.close .profile-details {
  background: none;
}

.sidebar.close .profile-details {
  width: 78px;
}

.sidebar .profile-details .profile-content {
  display: flex;
  align-items: center;
}

.sidebar .profile-details img {
  height: 40px;
  width: 40px;
  object-fit: cover;
  border-radius: 16px;
  margin: 0 14px 0 12px;
  transition: all 0.5s ease;
  backdrop-filter: blur(70px);
  box-shadow: 10px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar.close .profile-details img {
  padding: 10px;
}

.sidebar .profile-details .profile_name,
.sidebar .profile-details .job {
  color: #444444;
  font-size: 18px;
  font-weight: 500;
  white-space: nowrap;
}

.sidebar.close .profile-details i,
.sidebar.close .profile-details .profile_name,
.sidebar.close .profile-details .job {
  display: none;
}

.sidebar .profile-details .job {
  font-size: 12px;
}

.home-section {
  position: relative;
  height: 100vh;
  left: 260px;
  width: calc(100% - 260px);
  transition: all 0.5s ease;
  background: brown;
  opacity: 0.2;
}

.sidebar.close~.home-section {
  left: 78px;
  width: calc(100% - 78px);
}

.home-section .home-content {
  height: 60px;
  display: flex;
  align-items: center;
}

.home-section .home-content .bx-menu,
.home-section .home-content .text {
  color: #11101d;
  font-size: 35px;
}

.home-section .home-content .bx-menu {
  margin: 0 15px;
  cursor: pointer;
}

.home-section .home-content .text {
  font-size: 26px;
  font-weight: 600;
}

@media (max-width: 420px) {
  .sidebar.close .nav-links li .sub-menu {
    display: none;
  }
}
<div >
  <div >
    <i class='bx bx-library'></i>
    <span >E-Library</span>
  </div>
  <ul >
    <li>
      <a href="#">
        <i class='bx bx-grid-alt'></i>
        <span >Dashboard</span>
      </a>
      <ul >
        <li><a  href="#">Category</a></li>
      </ul>
    </li>
    <li>
      <div >
        <a href="#">
          <i class='bx bx-collection'></i>
          <span >Category</span>
        </a>
        <i class='bx bxs-chevron-down arrow'></i>
      </div>
      <ul >
        <li><a  href="#">Category</a></li>
        <li><a href="#">HTML & CSS</a></li>
        <li><a href="#">JavaScript</a></li>
        <li><a href="#">PHP & MySQL</a></li>
      </ul>
    </li>
    <li>
      <div >
        <a href="#">
          <i class='bx bx-book-alt'></i>
          <span >Posts</span>
        </a>
        <i class='bx bxs-chevron-down arrow'></i>
      </div>
      <ul >
        <li><a  href="#">Posts</a></li>
        <li><a href="#">Web Design</a></li>
        <li><a href="#">Login Form</a></li>
        <li><a href="#">Card Design</a></li>
      </ul>
    </li>
    <li>
      <a href="#">
        <i class='bx bx-pie-chart-alt-2'></i>
        <span >Analytics</span>
      </a>
      <ul >
        <li><a  href="#">Analytics</a></li>
      </ul>
    </li>
    <li>
      <a href="#">
        <i class='bx bx-line-chart'></i>
        <span >Chart</span>
      </a>
      <ul >
        <li><a  href="#">Chart</a></li>
      </ul>
    </li>
    <li>
      <div >
        <a href="#">
          <i class='bx bx-plug'></i>
          <span >Plugins</span>
        </a>
        <i class='bx bxs-chevron-down arrow'></i>
      </div>
      <ul >
        <li><a  href="#">Plugins</a></li>
        <li><a href="#">UI Face</a></li>
        <li><a href="#">Pigments</a></li>
        <li><a href="#">Box Icons</a></li>
      </ul>
    </li>
    <li>
      <a href="#">
        <i class='bx bx-compass'></i>
        <span >Explore</span>
      </a>
      <ul >
        <li><a  href="#">Explore</a></li>
      </ul>
    </li>
    <li>
      <a href="#">
        <i class='bx bx-history'></i>
        <span >History</span>
      </a>
      <ul >
        <li><a  href="#">History</a></li>
      </ul>
    </li>
    <li>
      <a href="#">
        <i class='bx bx-cog'></i>
        <span >Settings</span>
      </a>
      <ul >
        <li><a  href="#">Settings</a></li>
      </ul>
    </li>
    <li>
      <div >
        <div >
          <img src="image/profile.jpg" alt="profileImg">
        </div>
        <div >
          <div >Sam</div>
          <div >Student</div>
        </div>
        <i class='bx bx-log-out'></i>
      </div>
    </li>
  </ul>
</div>
<section >
  <div >
    <i class='bx bx-menu'></i>
  </div>
</section>

CodePudding user response:

It seems like fixed position is creating problems with the backdrop-filter. Try to replace:

.sidebar .nav-links li:hover{
 backdrop-filter: blur(40px);
box-shadow: 10px 0 15px rgba(0,0,0,0.1);

}

with:

.sidebar .nav-links li:hover:not(.sidebar .nav-links li:last-child){
 backdrop-filter: blur(40px);
box-shadow: 10px 0 15px rgba(0,0,0,0.1);}

}

  • Related