Css_ Draw a triangle

Source: Internet
Author: User

Principle: Draw a Div, give the div a width of 0, give 4 border attributes, three of which can be hidden to get a triangle.

Very simple one principle, the project may rarely use, the amateur can play, in fact, the front end is very good to play. can achieve a variety of functions.

Css:

1{2        width: 0;  3        height: 0;  4        border-right: 50px solid transparent;  5        border-bottom: 50px solid blue;  6        border-left: 50px solid transparent;  7     }

Html:

1 <  class= "Test1"></div>

All code:

1 <!DOCTYPE HTML>2 <HTML>3 4     <Head>5         <MetaCharSet= "UTF-8">6         <title></title>7     </Head>8     <!--/*1.css style * / -9     <styletype= "Text/css">Ten . Test1{ One width:0; A Height:0; - Border-right:50px Solid Transparent; - Border-bottom:50px Solid Blue; the Border-left:50px Solid Transparent; -         } -          - . Test2{ + width:0; - Height:0; + Border-top:50px Solid Transparent; A Border-bottom:50px Solid Transparent; at Border-left:50px Solid Orange; -         } -          - . Test3{ - width:0; - Height:0; in Border-top:50px solid Black; - Border-right:50px Solid Transparent; to Border-left:50px Solid Transparent; +         } -          the . Test4{ * width:0; $ Height:0;Panax Notoginseng Border-top:50px Solid Transparent; - Border-right:50px Solid Red; the Border-bottom:50px Solid Transparent; +         } A     </style> the  +     <Body> -         <!--2.html Style - $         <Divclass= "Test1"></Div> $         <Divclass= "Test2"></Div> -         <Divclass= "Test3"></Div> -         <Divclass= "Test4"></Div> the     </Body> - Wuyi </HTML>
View Code

Today, on January 9, 2018, Brother Pony became our consultant. It's not our boss anymore. Well, you can have a meal.

is not to become mature point, Sao years.

Css_ Draw a triangle

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.