1

I want to give a div none rectangular shape (look at the image below to see, how div should look). I've tried several transforms, but couldn't achieve the desired result. Here is a code snippet

.container {
  height: 60px;
  background: #252b33;
  display: flex;
  align-items: flex-end;
}
.tab {
  background: #3b424b;
  height: 40px;
  width: 150px;
  margin: 0 50px
}
.tab1 {
  transform: skewX(-45deg);
}
.tab2 {
  transform: rotateX(45deg);
}
<div class="container">
  <div class="tab"></div>
  <div class="tab tab1"></div>
  <div class="tab tab2"></div>
</div>

enter image description here

My question is: How can I give a div shape shown in the image using CSS?

Misho Tek
  • 624
  • 2
  • 11
  • 22

1 Answers1

2

Use css as below to .tab

border-bottom: 40px solid #555;
border-left: 20px solid transparent;
border-right: 20px solid transparent;

See here:

.container {
  height: 60px;
  background: #252b33;
  display: flex;
  align-items: flex-end;
}
.tab {
  height: 40px;
  width: 150px;
  margin: 0 0px;
  border-bottom: 40px solid #555;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
}
<div class="container">
  <div class="tab"></div>
  <div class="tab tab1"></div>
  <div class="tab tab2"></div>
</div>
לבני מלכה
  • 15,925
  • 2
  • 23
  • 47