Vlasta Po
Vlasta Po

Reputation: 901

How to make CSS shaped button/border?

Please, can you give me tips on how to make shaped button/menu navigation? It should look like this:

menu items

I have tried something with borders, but it's working only if there is no text inside the div.

Here is the code I tried:

.border-right {
  font-size: 0px; line-height: 0%; width: 0px;
  width: 0px;
  border-top: 50px solid #93D1C1;
  border-bottom: 50px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
} 

It looks like this (Codepen)

Any ideas, please?

Upvotes: 1

Views: 456

Answers (1)

Yug Kapoor
Yug Kapoor

Reputation: 785

Is this what you are looking for? https://codepen.io/anon/pen/RgNbvV

body {
  background-color: #4F4135;
}
.border-right {
  font-size: 0px; line-height: 0%; width: 0px;
  width: 0px;
  border-top: 50px solid #93D1C1;
  border-bottom: 50px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
  display: inline-block;
}

.border-wrong {
  width: 100px;
  background-color: #93D1C1;
  display: inline-block;
  position: relative;
  z-index: 1;
  text-align: center;
  padding-top: 10px;
}
.border-wrong:after {
  position: absolute;
  content: "";
  z-index: -1;
  left: 0;
  right: 0;
  width: 0px;
  background-color: #93D1C1;
  border-top: 25px solid #93D1C1;
  border-bottom: 25px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
  display: inline-block;
  text-align: center;
}

Upvotes: 2

Related Questions