1

I would like to make my div have a pointy angle but I am not sure of what is the best way to do it.

.top-div {
  width: 310px;
  height: 25px;
  background-color: #A52432;
}
<div class="top-div"></div>

Pointy red div image

VXp
  • 11,598
  • 6
  • 31
  • 46
SW2702
  • 189
  • 2
  • 10

3 Answers3

2

For this kind of effect you could use CSS and make a clip-path like this:

.top-div {
      width: 310px;
      height: 25px;
      background-color: #A52432;
      -webkit-clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
      clip-path: polygon(0 0, 100% 0, 100% 100%, 15% 100%);
}
<div class="top-div"></div>
Meghan
  • 1,215
  • 11
  • 17
billy.farroll
  • 1,903
  • 2
  • 15
  • 23
1

You can do it with a simple linear-gradient() which has greater support than clip-path:

.top-div {
  width: 310px;
  height: 25px;
  background: linear-gradient(45deg, transparent 10%, #A52432 10.01%);
}
<div class="top-div"></div>
VXp
  • 11,598
  • 6
  • 31
  • 46
  • 1
    Interesting this will come in handy in the future thanks :) – SW2702 Jun 08 '18 at 08:34
  • 1
    Decide to use in current project due to support as linear-gradient is more supported than clip-path as seen here https://caniuse.com/#search=linear-gradient vs https://caniuse.com/#search=clip-path – SW2702 Jun 08 '18 at 08:53
0

A div is always a rectangle. I would suggest to place a svg with <polgon> on the divs position (see Polygons).

mixable
  • 1,068
  • 2
  • 12
  • 42