使用HTML+CSS 实现箭头流程步骤条-真实业务需求

这篇博客展示了如何使用HTML、CSS和JavaScript创建一个带有动态点亮效果的步骤条。通过CSS实现每个步骤的样式,包括三角形箭头和背景颜色,而JavaScript则用于根据指定步骤点亮对应的条目。代码示例详细,适用于前端开发者实现类似功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果图:

具体实现效果代码如下

HTML

<div class="container">
    <div class="navs">
        <ul>
            <li class="active">第一步</li>
            <li>第二步</li>
            <li>第三步</li>
            <li>第四步</li>
            <li>第五步</li>
            <li>完成</li>
        </ul>
    </div>
</div>

CSS

    <style>
        .navs {
            height: 50px;
            line-height: 50px;
            padding-top: 10px;
            padding-bottom: 10px;
            width: 100%;
        }

        .navs li {
            padding: 0 10px 0 30px;
            line-height: 50px;
            background: #DCEEFE;
            display: inline-block;
            color: #1E9FFF /*#50abe4*/;
            position: relative;
            width: 12.7%;
        }

        .navs li:after {
            content: '';
            display: block;
            border-top: 20px solid #DCEEFE;
            border-bottom: 20px solid #DCEEFE;
            border-left: 20px solid #fff;
            position: absolute;
            right: -20px;
            top: 0;
        }

        .navs li:after {
            content: '';
            display: block;
            border-top: 20px solid transparent;
            border-bottom: 20px solid transparent;
            border-left: 20px solid #DCEEFE;
            position: absolute;
            right: -20px;
            top: 0;
            z-index: 10;
        }

        .navs li:before {
            content: '';
            display: block;
            border-top: 20px solid #DCEEFE;
            border-bottom: 20px solid #DCEEFE;
            border-left: 20px solid #fff;
            position: absolute;
            left: 0px;
            top: 0;
        }

        .navs li:first-child {
            border-radius: 4px 0 0 4px;
            padding-left: 25px;
        }

        .navs li:last-child,
        .cssNavEnd {
            border-radius: 0px 4px 4px 0px;
            padding-right: 25px;
        }

        .navs li:first-child:before {
            display: none;
        }

        .navs li:last-child:after,
        .cssNavEnd:after {
            display: none;
        }

        .navs li.active {
            background: #1E9FFF;
            color: #fff;
        }

        .navs li.active:after {
            border-left-color: #1E9FFF;
        }

        .navs li.active:before {
            border-top: 20px solid #1E9FFF;
            border-bottom: 20px solid #1E9FFF;
        }
    </style>

JS实现点亮步骤条效果

<script>
    $(function () {
        gotoStep(1);
    });

    function gotoStep(step) {
        $(".navs li").slice(0, step).addClass("active");
    }
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明哥.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值