javascript - 用线连接元素

标签 javascript css lines

我正在尝试用水平白线连接图钉元素和时间轴元素。有谁知道如何使用 javascript 和 css 来做到这一点?请参阅下面的引用链接。

提前致谢。

  • 迈克

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%;
}

这是 fiddle :http://jsfiddle.net/AAPSg/

关于javascript - 用线连接元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12267846/

相关文章:

C++ 使用多条线创建圆的轮廓

javascript - React 渲染搞乱了我与 Masonry 的 ref 绑定(bind)

javascript - li 元素的子节点给出 [#text, <ul> … </ul> , #text]

javascript - 分页.js : How can I set up an additional page counter for only a few pages

html - 响应式 Bootstrap 轮播

c++ - OpenGL:并非所有卡都支持 GL_LINE SMOOTH;甚至不会画线,除非

javascript - 用户保存HTML5音频时如何控制文件名?

javascript - InnerText 不会在 html 中更新

css - 带渐变的圆形虚线边框

file - 如何让python从包含一首诗的文件中读取每隔一行