---
title: "play with arrow"
author: "yiminghe"
date: "2010-10-14T22:40:29Z"
tags: []
categories: ["Web前端"]
slug: "play-with-arrow"
draft: false
lastmod: "2010-10-14T23:34:22Z"
id: 785281
url: "https://yiminghe.iteye.com/blog/785281"
---

之前 taobaoUED 已经详细解释过[三角形画法](http://ued.taobao.com/blog/2010/08/04/css-border%E4%BD%BF%E7%94%A8%E5%B0%8F%E5%88%86%E4%BA%AB/) ，利用双三角重合实现一个清新的纯线条还是挺不错的：

**[demo 清新线条窗口](http://lite-ext.googlecode.com/svn/trunk/lite-ext/playground/arrow/arrow.html)**

关键是双三角的重和方法：

 

```
<div class="arrow_b">
        <div class="arrow_a">
        </div>
    </div>
```

 

用 a 盖着 b 即可：

 

```
 .arrow_b, .arrow_a {
        border: 10px solid red;
        border-color: red transparent transparent transparent;
        /*ie6 透明*/
        border-style:solid dashed dashed dashed;
        position: absolute;
        width: 0;
        height: 0;
        font-size: 0;
        /*窗口居中*/
        left: 50%;
        top: 100%;
    }

    .arrow_a {
        border-top-color: white;
        /*覆盖 b*/
        top: -11px;
        left: -10px;
    }
```

 

 

 

**动态大小：**

 

只需动态更新 a , b 三角形的大小，以及 b 的定位为 a 上方即可，注意由于 b 高宽为 0，则不能通过设置 a 宽高百分比数值一劳永逸，只能动态设置了。