1

I would like to create this specific div shape: Rectangular div with a little transparent triangle at the top-center of it

I have read on how to create custom shapes but I really don't get the logic.. Can someone here kindly help me on the drawing of such a shape or redirect me to a web that explain really well the logic behind it? thanks,

Harry
  • 87,580
  • 25
  • 202
  • 214
Tripduc
  • 31
  • 1
  • 11

3 Answers3

0

The idea is a box with zero width and height. The actual width and height of the arrow is determined by the width of the border. there is a great and simple tutorial at css-tricks website with little animation that shows exactly how it all happens.

moay
  • 65
  • 1
  • 10
0

you can design it like:

.rect {
            background: black;
            height: 50px;
            width: 150px;
            position: relative;
            overflow: hidden;
        }
        .rect:after {
            content: "";
            background: #ffffff;
            height: 50px;
            width: 50px;
            -moz-transform: rotate(45deg); 
            -ms-transform: rotate(45deg); 
            -webkit-transform: rotate(180deg); 
            -o-transform: rotate(180deg);
            transform: rotate(45deg);
            display: block;
            position: absolute;
            top:-35px;
            right: 50px;
            
        }
<div class="rect"></div>
Ambrish Pathak
  • 3,813
  • 2
  • 15
  • 30
0

You can achieve this by:

HTML:

<div class="block"> <div class="arrow-down"></div> </div>

CSS:

.arrow-down {
    width: 0; 
    height: 0; 
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;

    border-top: 20px solid #fff;
    position:absolute;
    top:0;
    left:50%;
}

.block{
   background-color:black;
   height: 200px;
   position:relative;
}