Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triangle shaped pointer / border on a horizontal line

Tags:

css

css-shapes

I am trying to create triangle shaped pointer/border on a horizontal line.

Here is an example of what I am trying to achieve:

Example

I tried manipulating the top border of a div, but everything I've done so far doesn't work at all.

like image 841
Alexander Lomov Avatar asked Nov 10 '14 06:11

Alexander Lomov


People also ask

What is the border triangle?

The point at which Germany, France and Switzerland converge and boats sail off towards the North Sea is also a transport hub for the supply of raw materials to Switzerland. A unique meeting place for three countries, languages and cultures.

How do you draw a curved triangle in CSS?

triangle element and pointer-events: auto; on the pseudo-elements). Otherwise, this could be achieved by wrapping . triangle in an element having the same width and height (and the same border-radius ) and overflow: hidden; .


1 Answers

There are several ways to achieve that and it probably depends on your layout. One solution is to use a rotated element with borders on two sides.

.triangle {
  background: green;
  border: 2px solid white;
  border-width: 2px 2px 0 0;
  transform: rotate(-45deg);
}

.box {
  background: green;
  width: 400px;
  height: 80px;
  position: relative;
}

.line {
  height: 39px;
  border-bottom: 2px solid white;
}

.triangle {
  background: green;
  border: 2px solid white;
  border-width: 2px 2px 0 0;
  transform: rotate(-45deg);
  position: relative;
  left: 300px;
  top: 28px;
  width: 20px;
  height: 20px;
}
<div class="box">
  <div class="line">
    <div class="triangle">
      </div>
    </div>
  </div>
like image 145
Paul Avatar answered Nov 15 '22 21:11

Paul