Css implementation triangle and application example, css triangle example

Source: Internet
Author: User

Css implementation triangle and application example, css triangle example

I 've talked a lot about css triangle implementation on the Internet, but I found that the triangle is generally up or down, and the left-to-right direction seems to have little to say. I tried it, it turns out that it is difficult to implement it in IE ~~ (Internet Explorer )...
When the width and height of an element are 0 and the border (border) is not 0, the border of the four corners overlaps with each other to divide the border at 45 degrees. It's awkward to say ~~~ The previous figure:
. 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;
Border-style: solid;
Border-width: 20px 20px 0px 20px;
Width: 0;
Height: 0;
}

 



How? Come out ~~

In the same way, we change it to the left-to-right,

 

Left:. triangle {
Border-color: transparent red transparent;
Border-style: solid;
Border-width: 20px 20px 20px 0px;
Width: 0;
Height: 0;
}

Right:. triangle {
Border-color: transparent red;
Border-style: solid;
Border-width: 20px 0px 20px 20px;
Width: 0;
Height: 0;
}

Great success !? Slow, what browser are you using? If you are not using IE6, congratulations! Next we will use IE6 (gnashing teeth ...),



Khan ~~~~

 

It turns out that IE6 is black by default ~~

Only use the proprietary Internet Explorer, and you need to ring the bell for the solution (~ _~)

First, use the underscore "_" in css hack "_"!

_ Border-top-color: white;
_ Border-bottom-color: white;
Then use chroma filter: _ filter: chroma (color = white );

In fact, it is to filter out unwanted edges!

Also add font-size: 0; line-height: 0;

In this way, the black background is completely removed:

 

. Triangle {
Border-color: 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
  1. <! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <Html>
  3. <Head>
  4. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
  5. <Title> css triangle </title>
  6. <Style>
  7. . TipArrow {
  8. /* Color on the right, other transparency */
  9. Border-color: transparent # e00 transparent;
  10. Border-style: solid;
  11. Border-width: 6px 6px 6px 0px;
  12. Padding: 0;
  13. Width: 0;
  14. Height: 0;
  15. /* Ie6 height fix */
  16. Font-size: 0;
  17. Line-height: 0;
  18. /* Ie6 transparent fix */
  19. _ Border-top-color: # dddddddd;
  20. _ Border-bottom-color: # dddddddd;
  21. _ Filter: chroma (color = # dddddddd );
  22. }
  23. </Style>
  24. </Head>
  25. <Body>
  26. <Div class = "tipArrow"/>
  27. </Div>
  28. </Body>
  29. </Html>
 

I know some of you want to see the results directly. Haha:

 

Download

The triangle is coming out. Let's look at an example of an application (combined with the fadeIn and fadeOut previously written ):

 

Http://kingkit.com.cn/KUI/Tip.html

 

Complete Packaging

 

 

  • Triangle3.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.