Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make cut-off corners with a border

I want to make a shape in html that has cutoff corners and with a borderline around the shape.

I can make cut-off shapes without a border like so:

html:

<div class="cut-off"></div>

css:

 .cut-off{
   position:relative;
   top:400px;
   left:400px;
   height:155px;
   width:200px;
   background:red;
}
.cut-off:after{
   position:absolute;
   bottom:0px; right:-20px;
   content:".";
   text-indent:-999px; overflow:hidden;
   display:block;
   width:0px; height:0px;
   border-top: 20px solid green;
   border-right: 20px solid transparent;
}
.cut-off:before{
   position:absolute;
   top:0; right:-20px;
   content:"#";
   text-indent:-999px; overflow:hidden;
   display:block;
   background:blue;
   width:20px; height:135px;
} 

Jfiddle here

Now i want a border that goes around the shape. How should i do that?

I want a shape that is something like this:

shape

Filled with a color.

like image 655
user1386906 Avatar asked Dec 30 '12 18:12

user1386906


People also ask

How do you cut a border corner in CSS?

Style the cut corner with the ::before pseudo-element and use the content property required while using the :: before pseudo-element to generate and insert content. Set the position to "absolute" and add the top and right, border-top and border-right properties.


1 Answers

By altering your html structure a little bit, I could make this

<div class="cut-off"></div>
<div class="cut-off2"></div>​


.cut-off{
position: relative;
width: 300px;
height: 150px;
border-bottom: 80px red solid;
border-right: 80px transparent solid;
}

.cut-off2{
position: absolute;
z-index: -1;
top:0;
left: 0;
width: 305px;
height: 150px;
border-bottom: 82px blue solid;
border-right: 80px transparent solid;
}

p{
position: absolute;
left: 0;
bottom:-40px;

}

Basically it adds another div under the existing one. For the cuttof effect it plays with border dimensions.

EDIT: I also provided a way of including content in the area.

like image 163
menislici Avatar answered Sep 23 '22 04:09

menislici