用CSS样式实现箭头效果代码

代码收藏 欲思 0评论

有时候网页中使用箭头以增强效果,一般的做法是使用图片,但是使用CSS样式也一样可以来实现“箭头效果”。而且效果非常绚丽。
具体的颜色代码可以根据自己的需要去替换!

代码如下:

<style type="text/css">

table{width:50%; font-size:14px; font-family:Arial; color:#333}
.arrow-top,.arrow-right,.arrow-bottom,.arrow-left{font-size:0; line-height:0; height:0; width:0; cursor:pointer}
.box{ border:1px solid #CCC; width:100px; height:100px; padding:10px; background:#EEE; margin:10px}
.arrow{ border-width:50px; border-color:red green blue black; border-style:solid solid solid solid}
.arrow-bottom{ border-width:50px; border-color:red transparent transparent transparent; border-style:solid dashed dashed dashed; border-bottom:none;}
.arrow-left{ border-width:50px; border-color:transparent green transparent transparent; border-style:dashed solid dashed dashed; border-left:none;}
.arrow-top{ border-width:50px; border-color:transparent transparent blue transparent; border-style:dashed dashed solid dashed; border-top:none;}
.arrow-right{ border-width:50px; border-color:transparent transparent transparent black; border-style:dashed dashed dashed solid; border-right:none;}
</style>

<table>
<tr>
<td>
<div class="box">
<div class="arrow"></div>
</div>
</td>
<td>
<p>.arrow{ border-width:50px; border-color:red green blue black; border-style:solid solid solid solid}</p>
</td>
</tr>
<tr>
<td>
<div class="box">
<div class="arrow-top"></div>
</div>
</td>
<td>
<p>.arrow-top{ border-width:50px; border-color:red transparent transparent transparent; border-style:solid dashed dashed dashed; border-bottom:none;}
</p>
</td>
</tr>
<tr>
<td>
<div class="box">
<div class="arrow-right"></div>
</div>
</td>
<td>
<p>.arrow-right{ border-width:50px; border-color:transparent green transparent transparent; border-style:dashed solid dashed dashed; border-left:none;}
</p>
</td>
</tr>
<tr>
<td>
<div class="box">
<div class="arrow-bottom"></div>
</div>
</td>
<td>
<p>.arrow-bottom{ border-width:50px; border-color:transparent transparent blue transparent; border-style:dashed dashed solid dashed; border-top:none;}
</p>
</td>
</tr>
<tr>
<td>
<div class="box">
<div class="arrow-left"></div>
</div>
</td>
<td>
<p>.arrow-left{ border-width:50px; border-color:transparent transparent transparent black; border-style:dashed dashed dashed solid; border-right:none;}
</p>
</td>
</tr>
</table>

用CSS样式实现箭头效果如下:

.arrow{ border-width:50px; border-color:red green blue black; border-style:solid solid solid solid}

.arrow-top{ border-width:50px; border-color:red transparent transparent transparent; border-style:solid dashed dashed dashed; border-bottom:none;}

.arrow-right{ border-width:50px; border-color:transparent green transparent transparent; border-style:dashed solid dashed dashed; border-left:none;}

.arrow-bottom{ border-width:50px; border-color:transparent transparent blue transparent; border-style:dashed dashed solid dashed; border-top:none;}

.arrow-left{ border-width:50px; border-color:transparent transparent transparent black; border-style:dashed dashed dashed solid; border-right:none;}

转载请注明:欲思博客 » 用CSS样式实现箭头效果代码

如果你觉得这篇文章或者我分享的主题对你有帮助,请支持我继续更新网站和主题 !捐赠本站
喜欢 (1)or分享 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址