用直线连接图元

Connecting Elements with a Line

本文关键字:图元 连接      更新时间:2023-09-26

我正在尝试用水平白线连接pin元素和timeline元素。有人知道如何使用javascript和css来做到这一点吗?请参阅下面的参考链接。

提前谢谢。

  • Mike

http://mikedemar.com/devresources/timeline/example.png

http://mikedemar.com/devresources/timeline/index.html

将标记放在带有overflow: hidden的容器中,并使用伪元素绘制线条:

HTML:

<ul>
    <li class="handleicon"></li>
    <li class="handleicon"></li>
    <li class="handleicon"></li>
</ul>

CSS:

ul {
    position: relative;
    overflow: hidden;
    height: 260px;
}
.handleicon {
    position: absolute;
    width: 33px;
    height: 50px;
    background: url(images/handlered.png);
}
.handleicon:before {
    content: '';
    width: 1px;
    height: 400px;
    background: #fff;
    position: absolute;
    top: 100%;
    left: 50%;
}

小提琴在这儿:http://jsfiddle.net/AAPSg/