<div class="triangle-up"><!--向上的三角--></div>
<div class="triangle-down"> <!--向下的三角--></div>
<div class="triangle-left"> <!--向左的三角--></div>
<div class="triangle-right"> <!--向右的三角--></div>
2、然后新建一个css文件style.css,并在index.html中引入,引入代码:<link rel="stylesheet" type="text/css" href="style.css">
3、先做向上的三角形,这里有两种写法,大家可以参考下。在css文件中输入以下代码:
第一种: .triangle-up {
width:0
height:0
border-left:30px solid transparent
border-right:30px solid transparent
border-bottom:30px solid #fff
}
第二种:.triangle-up {
width:0
height:0
border:30px solid transparent
border-bottom-color:#fff
}
4、接下来写向下的三角形,继续在css文件中输入以下代码:
.triangle-down {
width:0
height:0
border-left:20px solid transparent
border-right:20px solid transparent
border-top:20px solid #0066cc
}
5、然后是向左的三角形,代码为:
.triangle-left {
width:0
height:0
border-top:30px solid transparent
border-bottom:30px solid transparent
border-right:30px solid yellow
}
6、最后是向右的三角形,代码为:
.triangle-right {
width:0
height:0
border-top:50px solid transparent
border-bottom: 50px solid transparent
border-left: 50px solid green
}
使鼠标经过显示 css3 绘图三角形参考下面方法:<a class="tooltips" href="#tooltips">这就是Tooltips<span>这些附加的说明文字在鼠标经过的时候显示。
</span></a>
<style type="text/css">
/*Tooltips*/
.tooltips{
position:relative/*这个是关键*/
z-index:2
}
.tooltips:hover{
z-index:3
background:none/*没有这个在IE中不可用*/
}
.tooltips span{
display: none
}
.tooltips:hover span{ /*span 标签仅在 :hover 状态时显示*/
display:block
position:absolute
top:21px
left:9px
width:15em
border:1px solid black
background-color:#ccFFFF
padding: 3px
color:black
}
</style>