Drop-Down Menu

Drop-Down Menu

HTML CODE

      <div class="middle">
          <div class="menu">
              <li class="item" id="profile">
                  <a href="#profile" class="btn"><i class="fas fa-user"></i>Profile</a>
                  <div class="smenu">
                      <a href="#">Posts</a>
                      <a href="#">Picture</a>
                  </div>
              </li>

              <li class="item" id="messages">
                  <a href="#messages" class="btn"><i class="far fa-envelope-open"></i>Messages</a>
                  <div class="smenu">
                      <a href="#">New</a>
                      <a href="#">Sent</a>
                      <a href="#">Spam</a>
                  </div>
              </li>

              <li class="item" id="settings">
                  <a href="#settings" class="btn"><i class="far fa-address-card"></i>User Settings</a>
                  <div class="smenu">
                      <a href="#">Password</a>
                      <a href="#">Language</a>
                  </div>
              </li>

              <li class="item">
                  <a class="btn" href="#"><i class="fas fa-sign-out-alt"></i>Logout</a>
              </li>
          </div>
      </div>

CSS CODE

* {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    list-style: none;
    text-decoration: none;
    background: #000
}

.middle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}

.menu {
    width: 300px;
    overflow: hidden
}

.item {
    border-top: 1px solid #ff0000;
    overflow: hidden
}

.btn {
    display: block;
    padding: 16px 20px;
    background: #ff0000;
    color: #fff;
    position: relative;
}

    .btn:before {
        content: "";
        position: absolute;
        width: 14px;
        height: 14px;
        background: #ff0000;
        left: 20px;
        bottom: -7px;
        transform: rotate(45deg)
    }

    .btn i {
        margin-right: 10px;
        background: #ff0000
    }

.smenu {
    background: #333;
    overflow: hidden;
    transition: max-height .3s;
    max-height: 0;
}

    .smenu a {
        display: block;
        padding: 16px 26px;
        color: #fff;
        font-size: 14px;
        margin: 4px 0;
        position: relative;
    }

        .smenu a:before {
            content: "";
            position: absolute;
            width: 6px;
            height: 100%;
            background: #920000;
            left: 0;
            top: 0;
            transition: .3s;
            opacity: 0;
        }

        .smenu a:hover:before {
            opacity: 1;
        }

.item:target .smenu {
    max-height: 10em;
}

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started