【问题标题】:Stepper Angular 5|6 HTML CSS Onclick EventStepper Angular 5|6 HTML CSS Onclick 事件
【发布时间】:2019-10-17 02:55:38
【问题描述】:

我需要有关单击事件的帮助以了解我的步进器进度。

例如,当我点击 3 时,我在第 1 步,我将转到第 3 步

我尝试点击<li>,但不起作用

这是我的 html 和 CSS

<div class="row">
  <div class="col-xs-12 col-md-8 offset-md-2 block border">
    <div class="wrapper-progressBar">
      <ul class="progressBar">
        <li class="active"></li>
        <li class=""></li>
        <li></li>
        <li></li>
      </ul>
    </div>
  </div>
</div>

CSS

.wrapper-progressBar {
  width: 100%
}

.progressBar {
counter-reset: step;
}

.progressBar li {
  list-style-type: none;
  float: left;
  width: 21%;
  position: relative;
  text-align: center;
}

.progressBar li:before {
  cursor:pointer;
  content: counter(step);
  counter-increment: step;
  line-height: 30px;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  border: 1px solid #ddd;
  display: block;
  text-align: center;
  margin: 0 auto 10px;
  background-color: white
}

.progressBar li:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  background-color: #ddd;
  top: 15px;
  left: -50%;
  z-index: -1;
}

.progressBar li:first-child:after {
  content: none;
}

.progressBar li.active {
  color: green;
}

.progressBar li.active:before {
  border-color: green;
  background-color: white;
}

.progressBar li.active + li:after {
  background-color: green;
}

https://jsfiddle.net/kingstore/jL6qyft1/3/

“我期待这个”

【问题讨论】:

  • 感谢您的回答,但我使用的是 Angular 5|6 而不是 Angular Material
  • 我也有同样的担忧,Angular 材料提供了我们需要的所有功能,但仅使用引导程序可能看起来很难做到。
  • 你尝试过的 Angular 代码在哪里?
  • @MedDiv 我找到了一个 github 项目,我认为这正是我们想要的。 github.com/cwun/angular-multi-step-wizard

标签: html css angular progress stepper


【解决方案1】:

我认为您正在寻找(点击)事件绑定。

类似这样的:

<div class="row">
  <div class="col-xs-12 col-md-8 offset-md-2 block border">
    <div class="wrapper-progressBar">
      <ul class="progressBar">
        <li *ngFor="let n of number" [ngClass]="active" (click)="onActive()"></li>
      </ul>
    </div>
  </div>
</div>

检查这个:https://angular.io/guide/user-input

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 2013-09-16
    • 2014-04-04
    相关资源
    最近更新 更多