How to create a simple pentagram graphic using pure CSS3

Source: Internet
Author: User

We can use SVG, Canvas, CSS3 or background images to achieve the pentagram pattern and its hover effect.

The pseudo-element and transformation characteristics introduced by CSS3 make it very simple to implement the pentagram graph, and can be combined with a gradient to achieve a more beautiful effect.
So using a picture to achieve a pentagram is no longer necessary (images occupy extra requests, and the amount of data is large.) Unless you want to support a low-version desktop IE browser).

First we create a triangle, which is usually implemented using elements with a large size edge and 0 content size, and the code demonstrates:
. tri {    width:0;    height:0;    border-left:15px solid transparent;    border-right:15px solid transparent;    border-bottom:30px solid Red;}
In the second step, we use pseudo-elements: after and: Before to clone 2 triangles of the same size.
. tri:after,.tri:before {    width:0;    height:0;    border-left:15px solid transparent;    border-right:15px solid transparent;    border-bottom:30px solid Red;}
Then, we apply different rotation transformations on the above 2 pseudo-elements:
. tri:before {    transform:rotate (70deg);}. Tri:after {    transform:rotate ( -70deg);}

So we implemented a pentagram graphic (icon). We can achieve more geometric shapes in a similar way.

You can try it yourself through an online example: http://wow.techbrood.com/fiddle/10258

You can also think about how to implement a triangle with edges and gradients, and then refer to this implementation: http://wow.techbrood.com/fiddle/16978


by Iefreer


How to create a simple pentagram graphic using pure CSS3

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.