CSS implementation of the triangle, on-line talk a lot, but I found that generally are triangular upward or downward, left to right these two directions seem to speak very little, I tried a bit, found that the original in IE very difficult to engage ~ ~ (Evil IE) ... The
CSS implementation of the triangle principle is: When the width of the element is 0, the border (border) is not 0 o'clock, four corners of the border overlapping 45 degrees angle evenly divided. It's a very awkward speech. Last Picture:
. Triangle {
border-color:red green Blue pink;
Border-style: Solid
Border-width: 20px 20px 20px 20px;
width:0;
height:0;
}
<div class= "triangle"/>
</div>
So, what do we find when we leave a border?
. triangle {
border-color:red transparent transparent transparent;
Border-style:solid;
border-width:20px 20px 0px 20px;
width:0;
height:0;
}
How? Out of the Bar ~ ~
In the same way, we change to a left-to-right
Left:. Triangle {
Border-color:transparent red transparent transparent;
Border-style:solid;
border-width:20px 20px 20px 0px;
width:0;
height:0;
}
Right:. Triangle {
Border-color:transparent transparent transparent red;
Border-style:solid;
border-width:20px 0px 20px 20px;
width:0;
height:0;
}
The merit is caused!? Slow, what kind of browser do you use? If you use non-IE6 words, congratulations! Below we use IE6 (gnashing of teeth ing ... ),
Sweat ~ ~ ~
Originally, IE6 default to the background black ~ ~
Only with the use of IE proprietary East, to solve the bell need to ring people (~_~)
First of all, CSS hack, with the underscore "_"!
_border-top-color:white;
_border-bottom-color:white;
Then use chroma filter: _filter:chroma (color =white);
In fact, it is to filter off the edge!
also add font-size:0; line-height:0;
This completely removes the black background:
. triangle {
Border-color:transparent transparent transparent red;
Border-style:solid;
border-width:20px 0px 20px 20px;
font-size:0;
line-height:0;
width:0;
height:0;
_border-top-color:white;
_border-bottom-color:white;
_filter:chroma (color =white);
}
HTML+CSS:
JS Code
- <! DOCTYPE HTML public "-//W3C//DTD html 4.01//en" " http://www.w3.org/TR/html4/strict.dtd" >
- <meta http-equiv="Content-type" content= "text/html; Charset=utf-8 ">
- <title>css Triangle </title>
- <style>
- . tiparrow {
- / * Color on right, other transparent * /
- Border-color:transparent #e00 Transparent transparent;
- Border-style:solid;
- border-width:6px 6px 6px 0px;
- padding:0;
- width:0;
- height:0;
- / * IE6 height fix * /
- font-size:0;
- line-height:0;
- / * IE6 transparent fix * /
- _border-top-color: #dddddd;
- _border-bottom-color: #dddddd;
- _filter:chroma (color = #dddddd);
- }
- </style>
- <body>
- <div class="Tiparrow"/>
- </div>
- </body>
Know some students to directly see the effect, haha: look
Download
The triangle is coming out, so let's look at an example of the application (combining the previously written fadein,fadeout):
Http://kingkit.com.cn/KUI/Tip.html
Full Package
CSS implementation triangles and application examples