Now let's start making arrows!
Before you start, you need to know how to use CSS to draw a triangle, if it is not clear you can look at the pure CSS painting all kinds of graphics
We use two CSS pseudo-elements,before and after, which belong to inline elements, but can be changed with display, before and after are new features in CSS2 (now old), browsers are not aware of their compatibility.
The implementation code is as follows:
1 <!--CSS style, in the project can put the same property and attribute value pairs are written together, here is easy to learn -2 <style>3 . Divtest{4 position:Absolute;5 Left:100px;6 Height:40px;7 width:200px;8 Padding-left:30px;9 background:Red;Ten Line-height:40px; One } A . Divtest:before{ - content:"'; - position:Absolute; the Top:0; - Left:-20px; - Height:0; - width:0; + Border-top:20px Solid RGB (255, 0, 0); - Border-left:20px Solid #FFFFFF; + /*border-right:20px solid #AF9E9E;*/ A Border-bottom:20px Solid #FF0000; at background:Red; - } - . Divtest:after{ - content:"'; - position:Absolute; - Top:0; in Right:-20px; - Height:0; to width:0; + Border-top:20px Solid RGB (255, 255, 255); - Border-left:20px Solid #FF0000; the /*border-right:20px solid #AF9E9E;*/ * Border-bottom:20px Solid #FFFFFF; $ background:Red;Panax Notoginseng } - </style> the <Body> + <Divclass= "Divtest"> A This is an arrow the </Div>
:
This is an arrow
Here with the CSS pseudo-elements to achieve the front and back two small triangles, a white a red, respectively, added to the div block elements before and after, it becomes an arrow. Of course, the following arrows can also be implemented as a minor modification
This is an arrow
In addition to these, you can add styles to these arrows, such as gradients, projections, margins, rotations, etc.
Here is the code for the border, and look at the allocation principle at the edge:
1 <style>2 . Divtest1{3 width:0;4 Height:0;5 Border-top:40px Solid Blue;6 Border-left:40px Solid Red;7 Border-right: 40px solid Yellow;8 Border-bottom:40px Solid Green;9 }Ten </style> One <Divclass= "Divtest1"> </Div>
:
In this example, we can better understand the border.
Make arrows with CSS pseudo-elements