角度创建垂直时间轴

时间:2019-05-03 09:38:40

标签: html css angular sass

我想创建一个响应式垂直时间线,如下所示。 抱歉,我是CSS方面的后端开发人员。

enter image description here

我能够达到如下所示的目的

enter image description here

目前,我正在寻求有关将div定位为右图所示的帮助。

我打算使用bootstrap和fa图标

我的CSS:

$text-color: #373737;
$gray-base: #494949;
$gray-darker: #222;
$gray-dark: #333;
$gray: #555;
$gray-light: #777;
$gray-lighter: #eee;
$brand-primary: #1f9eba;
$brand-success: #59ba1f;
$brand-info: #5bc0de;
$brand-warning: #d1bd10;
$brand-danger: #ba1f1f;

/* Timeline */
.timeline {
  list-style: none;
  padding: 20px;
  position: relative;
  &:before {
    top: 40px;
    bottom: 0;
    position: absolute;
    content: " ";
    width: 3px;
    background-color: #eeeeee;
    left: 50%;
    margin-left: -1.5px;
  }
  .timeline-item {
    margin-bottom: 20px;
    position: relative;
    &:before,
    &:after {
      content: "";
      display: table;
    }
    &:after {
      clear: both;
    }
    .timeline-badge {
      color: #fff;
      width: 54px;
      height: 54px;
      line-height: 52px;
      font-size: 22px;
      text-align: center;
      position: absolute;
      top: 18px;
      left: 50%;
      margin-left: -25px;
      background-color: $gray-dark;
      border: 3px solid #ffffff;
      z-index: 100;
      border-top-right-radius: 50%;
      border-top-left-radius: 50%;
      border-bottom-right-radius: 50%;
      border-bottom-left-radius: 50%;
      i,
      .fa,
      .glyphicon {
        top: 2px;
        left: 0px;
      }
      &.primary {
        background-color: $brand-primary;
      }
      &.info {
        background-color: $brand-info;
      }
      &.success {
        background-color: $brand-success;
      }
      &.warning {
        background-color: $brand-warning;
      }
      &.danger {
        background-color: $brand-danger;
      }
    }
    .timeline-panel {
      position: relative;
      text-align: right;
      width: 46%;
      float: left;
      right: 16px;
      // border: 1px solid $gray-light;
      background: #ffffff;
      border-radius: 2px;
      padding: 20px;
      -webkit-box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175);
      box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175);
      &:before {
        position: absolute;
        top: 26px;
        right: -16px;
        display: inline-block;
        border-top: 16px solid transparent;
        border-left: 16px solid $gray-light;
        border-right: 0 solid $gray-light;
        border-bottom: 16px solid transparent;
        // content: " ";
      }
      .timeline-title {
        margin-top: 0;
        color: inherit;
      }
      .timeline-body > p,
      .timeline-body > ul {
        margin-bottom: 0;
      }
      .timeline-body > p + p {
        margin-top: 5px;
      }
    }    
  }
  .timeline-item:last-child {
    &:nth-child(even) {
      float: right;
    }
  }
  .timeline-item:nth-child(even) {
    .timeline-panel {
      float: right;
      text-align: left;
      left: 16px;
      &:before {
        border-left-width: 0;
        border-right-width: 14px;
        left: -14px;
        right: auto;
      }
    }
  } 
}
// .timeline-horizontal:extend(.timeline) {
//   list-style: none;
//   position: relative;
//   padding: 20px 0px 20px 0px;
//   display: inline-block;
//   &:before {
//     height: 3px;
//     top: auto;
//     bottom: 26px;
//     left: 56px;
//     right: 0;
//     width: 100%;
//     margin-bottom: 20px;
//   }
//   .timeline-item {
//     display: table-cell;
//     height: 280px;
//     width: 20%;
//     min-width: 320px;
//     float: none !important;
//     padding-left: 0px;
//     padding-right: 20px;
//     margin: 0 auto;
//     vertical-align: bottom;
//     .timeline-panel {
//       top: auto;
//       bottom: 64px;
//       display: inline-block;
//       float: none !important;
//       left: 0 !important;
//       right: 0 !important;
//       width: 100%;
//       margin-bottom: 20px;
//       &:before {
//         top: auto;
//         bottom: -16px;
//         left: 28px !important;
//         right: auto;
//         border-right: 16px solid transparent !important;
//         border-top: 16px solid $gray-light !important;
//         border-bottom: 0 solid $gray-light !important;
//         border-left: 16px solid transparent !important;
//       }
//     }
//     &:before,
//     &:after {
//       display: none;
//     }
//     .timeline-badge {
//       size: 3em;
//       top: auto;
//       bottom: 0px;
//       left: 43px;
//     }
//   }
// }

我的HTML:

<div class="row">
  <div class="col-md-12">
    <div class="page-header">
      <h1>Timeline</h1>
    </div>
    <ul class="timeline">
      <li class="timeline-item">
        <div class="timeline-badge">
          <fa-icon [icon]="faCheck"></fa-icon>
        </div>
        <div class="timeline-panel">
          <div class="timeline-heading">
            <h4 class="timeline-title">Mussum ipsum cacilds 1</h4>
            <p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> 11 hours ago via Twitter</small></p>
          </div>
        </div>
        <div style="float: right; position: relative;text-align: right;"> Hello </div>
      </li>
      <li class="timeline-item">
        <div class="timeline-badge"><i class="glyphicon glyphicon-check"></i></div>
        <div class="timeline-panel">
          <div class="timeline-heading">
            <h4 class="timeline-title">Mussum ipsum cacilds 2</h4>
            <p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> 11 hours ago via Twitter</small></p>
          </div>
          <div class="timeline-body">
            <p>Test</p>
          </div>
        </div>
      </li>
      <li class="timeline-item">
        <div class="timeline-badge"><i class="glyphicon glyphicon-check"></i></div>
        <div class="timeline-panel">
          <div class="timeline-heading">
            <h4 class="timeline-title">Mussum ipsum cacilds 3</h4>
            <p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> 11 hours ago via Twitter</small></p>
          </div>
          <div class="timeline-body">
            <p>Test Content 1 </p>
            <p>Test Content 2 </p>

          </div>
        </div>
      </li>
      <li class="timeline-item">
        <div class="timeline-badge"><i class="glyphicon glyphicon-check"></i></div>
        <div class="timeline-panel">
          <div class="timeline-heading">
            <h4 class="timeline-title">Mussum ipsum cacilds 4</h4>
            <p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> 11 hours ago via Twitter</small></p>
          </div>
          <div class="timeline-body">
            <p>Test </p>
          </div>
        </div>
      </li>
    </ul>
  </div>
</div>

注意:我从https://codepen.io/wdmg/pen/ZWmwNM

提取了此示例

非常感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

Fiddle下面检查更新的 SELECT DISTINCT (SELECT COUNT (*) FROM posts WHERE posts.forum_type_id = '1') AS generalCount,forum.id (SELECT COUNT(*) FROM posts WHERE posts.forum_type_id = '2') AS questionsCount, forum.id FROM forum;

更新的CSS

css

答案 1 :(得分:0)

这对我有用

结果

enter image description here

代码:

<html><body>

<style> 
.bold{font-weight:bold;}
.time{position:absolute; left:-110px;}
.timeline-wrapper {
padding-left:80px;
min-width: 400px;
font-family: 'Helvetica';
font-size: 14px;
/*border: 1px solid #CCC;*/
}
.StepProgress {
position: relative;
padding-left: 45px;
list-style: none;
}
.StepProgress::before {
display: inline-block;
content: '';
position: absolute;
top: 0;
left: 15px;
width: 10px;
height: 100%;
border-left: 2px solid #CCC;
}
.StepProgress-item {
position: relative;
counter-increment: list;
}
.StepProgress-item:not(:last-child) {
padding-bottom: 20px;
}
.StepProgress-item::before {
display: inline-block;
content: '';
position: absolute;
left: -30px;
height: 100%;
width: 10px;
}
.StepProgress-item::after {
content: '';
display: inline-block;
position: absolute;
top: 0;
left: -37px;
width: 12px;
height: 12px;
border: 2px solid #CCC;
border-radius: 50%;
background-color: #FFF;
}
.StepProgress-item.is-done::before {
border-left: 2px solid green;
}
.StepProgress-item.is-done::after {
/*content: "?";*/
font-size: 10px;
color: #FFF;
text-align: center;
border: 2px solid green;
background-color: green;
}
/*.StepProgress-item.current::before { 
border-left: 2px solid green;
}
.StepProgress-item.current::after {
content: counter(list);
padding-top: 1px;
width: 19px;
height: 18px;
top: -4px;
left: -40px;
font-size: 14px;
text-align: center;
color: green;
border: 2px solid green;
background-color: white;
}*/
.StepProgress strong {
display: block;
}
</style>

<div class="timeline-wrapper"> 
 <ul class="StepProgress">
        <li class="StepProgress-item is-done">
            <div class="bold time">10:00 Am</div> 
            <div class="bold">Step 1</div>
        </li>
        <li class="StepProgress-item is-done">
            <div class="bold time">11:00 Am</div> 
            <div class="bold">Step 2</div>
            <div>En proceso</div>
        </li>
        <li class="StepProgress-item current">
            <div class="bold time">12:00 Pm</div> 
            <div class="bold">Step 3</div>
        </li>
        <li class="StepProgress-item">
            <div class="bold time">01:00 Pm</div> 
            <div class="bold">Step 4</div>
        </li>
        <li class="StepProgress-item">
            <div class="bold time">02:00 Pm</div> 
            <div class="bold">Step 5</div>
        </li>
    </ul>
</div>

</body></html>