-1

I am using ant-d navigation bar and i have to make an outward border like given in image. how can i achieve this? enter image description here

Arslan ali
  • 43
  • 6

1 Answers1

0

You can give every menu item a top and bottom div to go along with each menu item and then style it to give you your border radius. Look at this example I made for you:

var header = document.getElementById("cont");
var btns = header.getElementsByClassName("containerblue");
for (var i = 0; i < btns.length; i++) {
  btns[i].addEventListener("click", function() {
  var current = document.getElementsByClassName("active");
  current[0].className = current[0].className.replace(" active", "");
  this.className += " active";
  });
}
.container{
  background-color: skyblue;
  width: 300px;
}

.containerblue{
  background-color: blue;
  width: 20px;
  padding-left: 25px;
}


.containerblue.active > .top {
  background-color: blue;
  width: 200px;
  height: 25px;
  border-radius: 0px 0px 25px 0px;
  pointer-events: none;
}

.containerblue.active > .middle{
  background-color: skyblue;
  width: 200px;
  border-radius: 25px;
  padding: 20px;
}

.containerblue.active > .bottom {
  background-color: blue;
  width: 200px;
  height: 25px;
  border-radius: 0px 25px 0px 0px;
  pointer-events: none;
}


.top{
  background-color: blue;
  width: 200px;
  height: 25px;
  pointer-events: none;
}

.middle{
  background-color: blue;
  width: 200px;
  padding-top: 20px;
  padding-bottom: 20px;
  cursor: pointer;
  color: white;
}

.bottom{
  background-color: blue;
  width: 200px;
  height: 25px;
  pointer-events: none;
}
<div class="container" id="cont">
   <div class="containerblue active">
    <div class="btn top"></div>
    <div class="btn middle">Search</div>
    <div class="btn bottom"></div>
  </div>
   <div class="containerblue">
    <div class="btn top"></div>
    <div class="btn middle">Contracts</div>
    <div class="btn bottom"></div>
  </div>
   <div class="containerblue">
    <div class="btn top"></div>
    <div class="btn middle">Etc.</div>
    <div class="btn bottom"></div>
  </div>
</div>
John
  • 5,132
  • 1
  • 6
  • 17
  • Thank you so much for the answer. I understand your solution, but now the problem is how do i append the top and bottom div ? i am using reactJS. i am very new in react so i am confused as how to append the divs in the navigation. – Arslan ali Nov 30 '20 at 10:29
  • @Arslanali I've edited my answer. I went ahead and made a fully functional menu for you. Take a look. – John Nov 30 '20 at 10:49
  • Again thank you so much..... – Arslan ali Nov 30 '20 at 11:22