设置表单向导的样式

J86*_*J86 2 html css html5 css3

是否可以在HTML5和CSS3中编写如下代码?

形式向导

我可以很好地用它们里面的数字做圆圈,但我不知道怎么去连接台阶的线/路?

我想到的标记是:

<ul>
    <li><span>1</span></li>
    <li><span>2</span></li>
    <li><span>3</span></li>
    <li><span>4</span></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

Jam*_*lly 6

是的,这是可能的.JSFiddle演示.

例

HTML

span我只是使用以下标记,而不是将数字包装在元素中:

<ul class="steps">
    <li class="active">1</li>
    <li class="active">2</li>
    <li>3</li>
    <li>4</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

然后我使用:before伪元素在li第一个之前插入该行:

CSS

ul.steps {
    background: tomato;
    display: block;
    list-style-type: none;
    padding: 10px;
    width: 300px;
}

ul.steps li {
    border-radius: 42%;
    background: #DB4024;
    color: #FFB3B3;
    display: inline-block;
    height: 32px;
    line-height: 32px;
    margin-right: 53px;
    position: relative;
    text-align: center;
    width: 32px;
}

ul.steps li:last-child {
    margin-right: 0;
}

ul.steps li:before {
    background: #DB4024;
    content: '';
    display: block;
    height: 10px;
    right: 30px;
    position: absolute;
    top: 11px;
    width: 59px;
}

ul.steps li:first-child:before {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

然后我给它了.active样式(使背景变白并且颜色变黑):

ul.steps li.active, ul.steps li.active:before {
    background: #fff;
    color: #333;
}
Run Code Online (Sandbox Code Playgroud)

笔记:

  1. 在这个例子中,我使用了固定宽度值.在ulli宽度和li利润率和位置偏移量将需要由你相应的调整.
  2. class="active"将需要添加到所有突出显示的li元素,而不仅仅是当前元素.
  3. li由于线必须在平坦边缘上与它们相遇,因此元件不是完美的圆.