Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add bordered triangle over a div tag

Tags:

I have a div tag,

 __________
|          |    
|          |    
|          |    
|__________|

I want to add a small triangle over it.

 _______/\_
|          |    
|          |    
|          |    
|__________|

Note: I want my div tag with border of certain color, and div body of another. Say, my div background will be white and border should be blue. See this please. http://fiddle.jshell.net/pausP/

like image 420
Mercurial Avatar asked Apr 26 '13 13:04

Mercurial


1 Answers

Using the initial box with pointer and shadows at http://cssarrowplease.com/ you can restyle them to make the shape you want:

.arrow_box {    top: 40px;    position: relative;    background: #ffffff;    border: 1px solid #719ECE;  /*set border colour here*/    width: 200px;    height: 200px;    border-radius: 3px;    -webkit-filter: drop-shadow(0 1px 10px rgba(113, 158, 206, 0.8)); /*set shadow colour  and size here*/    -moz-box-shadow: 0 1px 10px rgba(113, 158, 206, 0.8);    filter: drop-shadow(0 1px 10px rgba(113, 158, 206, 0.8));  }    .arrow_box:after,  .arrow_box:before {    bottom: 100%;    border: solid transparent;    content: " ";    height: 0;    width: 0;    position: absolute;    pointer-events: none;  }    .arrow_box:after {    border-color: rgba(255, 255, 255, 0);    border-bottom-color: #ffffff;    border-width: 19px;    left: 50%;    margin-left: -19px;  }    .arrow_box:before {    border-color: rgba(113, 158, 206, 0);    border-bottom-color: #719ECE;    border-width: 20px;    left: 50%;    margin-left: -20px;  }
<div class="arrow_box">  </div>

if you need to move the arrow further right, then just play with the left for .arrow_box:after and .arrow_box:before

like image 58
Pete Avatar answered Oct 31 '22 20:10

Pete