Reputation: 9269
I'm working with CSS3 and I'm doing some bubbles.
I have a problem, I need to have a triangle with 1px border, but with my code I have a fat triangle..
Here my fiddle : FIDDLE
And the code :
<p class="triangle-border right">hi hi</p>
.triangle-border {
position:relative;
padding:15px;
color:#333;
background:#fff;
margin-left:100px;
margin-right:100px;
}
.triangle-border.right {
margin-right:50px;
border:3px solid #EEEEEF;
}
.triangle-border:before {
content:"";
position:absolute;
bottom:-20px; /* value = - border-top-width - border-bottom-width */
left:40px; /* controls horizontal position */
border-width:20px 20px 0;
border-style:solid;
border-color:#EEEEEF transparent;
/* reduce the damage in FF3.0 */
display:block;
width:0;
}
/* creates the smaller triangle */
.triangle-border:after {
content:"";
position:absolute;
bottom:-13px; /* value = - border-top-width - border-bottom-width */
left:47px; /* value = (:before left) + (:before border-left) - (:after border-left) */
border-width:13px 13px 0;
border-style:solid;
border-color:#fff transparent;
/* reduce the damage in FF3.0 */
display:block;
width:0;
}
/* creates the larger triangle */
.triangle-border.right:before {
top:10px; /* controls vertical position */
bottom:auto;
left:auto;
right:-30px; /* value = - border-left-width - border-right-width */
border-width:15px 0 15px 30px;
border-color:transparent #EEEEEF;
}
/* creates the smaller triangle */
.triangle-border.right:after {
top:16px; /* value = (:before top) + (:before border-top) - (:after border-top) */
bottom:auto;
left:auto;
right:-21px; /* value = - border-left-width - border-right-width */
border-width:9px 0 9px 21px;
border-color:transparent #fff;
}
Do you see the triangle on the right ? I need a triangle with just 1px of border.. Thanks !
Upvotes: 0
Views: 128
Reputation: 1
You can see it working Here: FIDDLE
.triangle-border.right:before {
border-color: rgba(0, 0, 0, 0) #EEEEEF;
border-width: 15px 0 13px 27px;
bottom: auto;
left: auto;
right: -28px;
top: 11px;
width: 0;
}
.triangle-border:before {
border-color: #EEEEEF rgba(0, 0, 0, 0);
border-style: solid;
content: "";
height: 0;
position: absolute;
}
.triangle-border.right:after {
border-color: rgba(0, 0, 0, 0) #FFFFFF;
border-width: 10px 0 11px 23px;
bottom: auto;
left: auto;
right: -23px;
top: 15px;
}
.triangle-border:after {
border-color: #FFFFFF rgba(0, 0, 0, 0);
border-style: solid;
content: "";
display: block;
position: absolute;
width: 0;
}
.triangle-border.right {
border: 3px solid #EEEEEF;
margin-right: 50px;
}
.triangle-border {
background: none repeat scroll 0 0 #FFFFFF;
color: #333333;
margin-left: 100px;
padding: 15px;
position: relative;
}
Just made it to fit with your current border width, but you can play with
.triangle-border.right:before
class to adjust it with any border size.
That's too much code for a single triangle , You can refer this link : Tutorial On Speech Bub
Upvotes: 0
Reputation: 25954
/* creates the larger triangle */
.triangle-border.right:before {
top:14px; /* controls vertical position */
bottom:auto;
left:auto;
right:-22px; /* value = - border-left-width - border-right-width */
border-width:11px 0 11px 22px;
border-color:transparent #EEEEEF;
}
I just played with the border-width and top/left positioning
Upvotes: 2