2

In my case i have something following this:

http://jsfiddle.net/pyx3zx25/12/

and the question is how can i add the border also to triangle.

My css:

.slide{
    position: relative;
    padding: 15px;    
}        
.arrow {
    max-width: 300px;
    background-color: #E01616;
    position: absolute;
    top: -10px;
    left: -10px;
    margin: 5px 0 0 5px;
    border: 3px solid black;
}
.arrow:after {
    left: 100%;
    bottom: 0px;
    content: "";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
    border-width: 15px;
    border-bottom: 30px solid #E01616;
    border-right: 30px solid transparent;
}
Harry
  • 87,580
  • 25
  • 202
  • 214
vardius
  • 6,326
  • 8
  • 52
  • 97
  • There are a couple of ways. You can use another pseudo (`:before`) and position it slightly below the `:after` or use `transform` to rotate a `div` by 45 deg. I think there are already a few similar questions out there. – Harry Sep 18 '14 at 11:16

3 Answers3

4

Use the :before pseudo-element to create a like-for-like triangle with just a few adjustments, to make it seem like your :after element has a border:

.slide{
    position: relative;
    padding: 15px;    
}        
.arrow {
    max-width: 300px;
    background-color: #E01616;
    position: absolute;
    top: -10px;
    left: -10px;
    margin: 5px 0 0 5px;
    border: 3px solid black;
}
.arrow:after {
    left: 100%;
    bottom: 0px;
    content: "";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
    border-width: 15px;
    border-bottom: 30px solid #E01616;
    border-right: 30px solid transparent;
}

.arrow:before {
    left: 100%;
    bottom: -3px;
    content: "";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
    border-width: 15px;
    border-bottom: 37px solid #000;
    border-right: 37px solid transparent;
}
<div class="slide">
    <div class="arrow">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer scelerisque ex eget ultricies blandit.</p>
    </div>
</div>
George
  • 36,413
  • 9
  • 66
  • 103
0

You can't use border because you use it already.

Try it. UPDTATE

.arrow:before{
     border-bottom: 40px solid #000;
    border-right: 37px solid transparent;
    border-width: 0 37px 40px 0;
    bottom: 0;
    content: "";
    left: 100%;
    position: absolute;
    top: 55px;

}
Mukul Kant
  • 7,074
  • 5
  • 38
  • 53
0

jsfiddle - jsfiddle

HTML

 <div class="slide">
    <div class="arrow">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer scelerisque ex eget ultricies blandit.</p>
    </div>
 </div>

CSS

.slide{
    position: relative;
    padding: 15px;    
}        
.arrow {
    max-width: 300px;
    background-color: #E01616;
    position: absolute;
    top: -10px;
    left: -10px;
    margin: 5px 0 0 5px;
    border: 3px solid black;
}
.arrow:after {
    left: 100%;
    bottom: 0px;
    content: "";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
    border-width: 15px;
    border-bottom: 30px solid #E01616;
    border-right: 30px solid transparent;
    box-shadow: 0px 3px 0px 0px #000;
}
.arrow:before{
   content: "";
    right: -30px;
    bottom: 0px;
    height: 3px;
    width: 30px;
    position: absolute;
    background: #000;
    pointer-events: none;
    transform: rotate(45deg) translate(-8px,-11px) scale(1.45);  
}
Darshak Shekhda
  • 646
  • 5
  • 7