skip to Main Content

guys! I make a navbar and ran into a problem that I don’t know how to make mark up of the active tab.

Screenshot of active tab

2

Answers


  1. body {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    .navbar {
      display: flex;
      align-items: center;
      padding: 20px;
      padding-bottom: 0px;
      background-color: #ededed;
      border-bottom: 3px solid #d2a0d7;
    }
    
    .navlink {
      text-decoration: none;
      color: black;
      padding: 10px 30px;
    }
    
    .active {
      background-color: #d2a0d7;
      border-radius: 10px 10px 0 0;
    }
    <div class="navbar">
      <a href="#" class="navlink active">Home</a>
      <a href="#" class="navlink">About</a>
      <a href="#" class="navlink">Contact</a>
    </div>
    Login or Signup to reply.
  2. I have added am bottom shadow as well, and its looks like this –

    enter image description here

    HTML CODE

    body {
      margin: 0;
      background-color: #F7F0D0;
      padding: 0;
      box-sizing: border-box;
    }
    
    .navbar {
      display: flex;
      align-items: center;
      padding: 20px;
      padding-bottom: 0px;
      background-color: #ededed;
      border-bottom: 3px solid #d2a0d7;
    }
    
    .navlink {
      text-decoration: none;
      color: black;
      padding: 10px 30px;
      position: relative;
    }
    
    .active {
      padding: 10px 15px;
      background-color: #d2a0d7;
      position: relative;
      border-top-left-radius: 10px;
      border-top-right-radius: 10px;
    }
    
    .active:before,
    .active:after {
      content: "";
      position: absolute;
      height: 5px;
      width: 20px;
      bottom: 0;
    }
    
    .active:after {
      right: -20px;
      border-radius: 0 0 0 10px;
      box-shadow: -10px 0 0 0 #d2a0d7;
    }
    
    .active:before {
      left: -20px;
      border-radius: 0 0 10px 0;
      box-shadow: 10px 0 0 0 #d2a0d7;
    }
    <div class="navbar">
      <a href="#" class="navlink active">Home</a>
      <a href="#" class="navlink">About</a>
      <a href="#" class="navlink">Contact</a>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search