纯css样式 箭头和三角形
2015-05-04 23:18
260 查看
最近学习css的样式,终于有时间把自己的心得写出来。用纯css样式实现简单的箭头和“<"">"例子,方法有两个,本质都差不多从一条边拉伸到另一个方向形成箭头。平时网页编写中经常遇到箭头,我们除了图片外,用纯css实现下面效果代码如下:
#a{ width: 0; height: 0; border: 50px solid transparent; border-top-color: #000000; /*position: relative;*/ } #b{ width: 0; height: 0; border: 40px solid transparent; border-top-color: white; /* position: absolute;*/ margin-top: -50px; margin-left: -40px;}
<div id="a"> <div id="b"></div> </div>实现箭头代码关键是设width和height为0;代码如下:
.up { width:0; height:0; border-left:50px solid transparent; border-right:50px solid transparent; border-bottom:50px solid #000000; } /*箭头向下*/ .down { width:0; height:0; border-left:50px solid transparent; border-right:50px solid transparent; border-top:50px solid #bb8ccc; } /*箭头向左*/ .left { width:0; height:0; border-top:50px solid transparent; border-bottom:50px solid transparent; border-right:50px solid #ff2a28; } /*箭头向右*/ .right { width:0; height:0; border-top:50px solid transparent; border-bottom: 50px solid transparent; border-left: 50px solid #793380; }<body> <!--向上的三角--><div class="up"> </div> <!--向下的三角--><div class="down"> </div> <!--向左的三角--><div class="left"> </div><!--向右的三角--><div class="right"></div></body>另一种实现如图实现的代码如下:
#box{width: 0;height: 0;border: 50px solid transparent;border-top-color: #5ffa28;border-right-color: #ff4e24;border-bottom-color: #d26b7b;border-left-color: #2549ff;}
<div id="box"></div>
相关文章推荐
- css制作导航栏小三角形箭头 .clearance-product-title span.active:after ,.clearance-product-title span:hover:afte
- 纯 CSS 实现三角形尖角箭头的实例
- css不用旋转实现返回箭头,圆点,三角形
- css整理 -- 右箭头,上下箭头,三角形
- Latex 箭头、下标、符号上下写文字、正方形和三角形
- css样式中三角形的应用
- 纯 CSS 实现三角形尖角箭头的实例
- 用css3写三角形和三角箭头并旋转
- 自定义带三角形箭头的TextView
- css不用旋转实现返回箭头,圆点,三角形
- CSS制作箭头图标代码(圆,三角形,椭圆)
- 纯CSS实现箭头、气泡让提示功能具有三角形图标
- css简单实现三角形箭头
- html css样式绘制向下或者向上箭头
- 纯CSS实现箭头、气泡让提示功能具有三角形图标(简单实例)
- 纯CCS绘制三角形箭头图案
- 学习笔记---整理资料翻出的旧练习,输出实心和空心图形:矩形,三角形,菱形,箭头,心形
- 淘宝和QQ空间顶部工具栏三角形箭头的实现方式
- CSS样式写出三角形
- 纯css绘制 三角形 ,箭头