新闻中心 网络推广 网站建设 优化推广 首页>新闻>网站建设

基于bootstrap框架写的垂直时间轴

时间:2025-03-09   访问量:0

基于bootstrap框架写的垂直时间轴

先是HTML代码,循环输出数据:

    <div class="story-box">
          {hmcms:list num=20   order='sorting asc,id asc'  page=0}              
        <div class="story-list-box wow fadeInUp" >
              <div class="num ">[list:title]</div>
              <div class="year fs-28">[list:title]年</div>
              <div class="fs-16">[list:content]</div>

              <div class="time-line"></div>
          </div>
          {/hmcms:list}
      </div>


然后是CSS:

/*******发展历程************************/

 
.story-box{
       background: url(../images/storybg.png) top center repeat-y;
    }

.story-list-box{
         position: relative;
        padding: 89px 30px 63px 30px;
        box-shadow: 0 0 24px rgba(18, 35, 62, 0.05);
        background-color: #ffffff;
        z-index: 2;
        text-align: center;
        border-radius: 30px;
        margin-bottom: 30px;
        width:45%;    
    }
    .story-list-box .time-line{
         position: absolute;
         right: -110px;
         top:100px;
         width: 80px;
         height: 80px;
         overflow: hidden;
         
    }
    
.story-list-box .time-line::before {
    content: "";
    position: absolute;
    top: 0px;
    left: 10px;
    width: 0;
    height: 0;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-right: 40px solid #16619E;
}


.story-list-box:nth-child(2n) .time-line:before {
    content: "";
    position: absolute;
    top: 0px;
    left: 40px; 
    width: 0;
    height: 0;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-left: 40px solid #16619E; /* 改成 border-left 实现反向三角 */
}

    .story-list-box:nth-child(2n){
        margin-left:55%
    }

    .story-list-box:nth-child(2n) .time-line{
        right:auto;
        left:-120px;
    }

    .story-list-box .num{
           position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: #F4F8FF;
    font-size: 160px;
    line-height: 1;
    z-index: -1;
    font-family: 'enbold';
    }

    .story-list-box .year{
      line-height: 38px;
    color: #333333;
    margin-bottom: 20px;
    font-family: 'enbold';
    }


最终效果是左右排列:

image.png

服务咨询
1对1咨询,专业客服为您解疑答惑
联系销售
15899750475
在线咨询
联系在线客服,为您解答所有的疑问
ARE YOU INTERESTED IN ?
感兴趣吗?

有关我们服务的更多信息,请联系项目经理

15899750475 杨先生