gpt4 book ai didi

html - 圆形台阶指示器台阶名称位置

转载 作者:搜寻专家 更新时间:2023-10-31 08:29:56 27 4
gpt4 key购买 nike

我正在为我的表单构建步骤指示器。
我在 codepen 上找到了很好的例子,我正在尝试根据我的需要对其进行自定义。

HTML 结构如下所示:

<div class="progress">
<div class="circle done">
<span class="label">1</span>
<span class="title">Order informations</span>
</div>

<span class="bar done"></span>

<div class="circle">
<span class="label">4</span>
<span class="title">Order review</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">5</span>
<span class="title">Finish</span>
</div>
</div>

和 CSS:

*, *:after, *:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family:"Open Sans";
}
/* Form Progress */
.progress {
width: 1000px;
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
}
.progress .circle, .progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
}
.progress .bar {
position: relative;
width: 80px;
height: 6px;
margin: 0 -5px 17px -5px;
border-left: none;
border-right: none;
border-radius: 0;
top: -16px;
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 30px;
margin-left: -5px;
}
/* Done / Active */
.progress .bar.done, .progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}

如果我用单个单词作为步骤描述,则一切都正确对齐,但如果我有两个单词,我会得到以下结果:

enter image description here

这是显示我的结果的代码片段:

var i = 1;
$('.progress .circle').removeClass().addClass('circle');
$('.progress .bar').removeClass().addClass('bar');
setInterval(function() {
$('.progress .circle:nth-of-type(' + i + ')').addClass('active');
$('.progress .circle:nth-of-type(' + (i - 1) + ')').removeClass('active').addClass('done');
$('.progress .circle:nth-of-type(' + (i - 1) + ') .label').html('&#10003;');
$('.progress .bar:nth-of-type(' + (i - 1) + ')').addClass('active');
$('.progress .bar:nth-of-type(' + (i - 2) + ')').removeClass('active').addClass('done');
i++;
if (i == 8) {
$('.progress .circle').removeClass().addClass('circle');
$('.progress .bar').removeClass().addClass('bar');
i = 1;
}
}, 1000);
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */

.progress {
width: 1000px;
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
}
.progress .circle,
.progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
}
.progress .bar {
position: relative;
width: 80px;
height: 6px;
margin: 0 -5px 17px -5px;
border-left: none;
border-right: none;
border-radius: 0;
top: -16px;
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 30px;
margin-left: -5px;
}
/* Done / Active */

.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<div class="progress">

<div class="circle done">
<span class="label">1</span>
<span class="title">Order</span>
</div>

<span class="bar done"></span>

<div class="circle done">
<span class="label">2</span>
<span class="title">Address</span>
</div>

<span class="bar half"></span>

<div class="circle active">
<span class="label">3</span>
<span class="title">Payment</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">4</span>
<span class="title">Review</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">5</span>
<span class="title">Finish</span>
</div>
</div>

<div class="progress">
<div class="circle done">
<span class="label">1</span>
<span class="title">Order informations</span>
</div>

<span class="bar done"></span>

<div class="circle">
<span class="label">4</span>
<span class="title">Order review</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">5</span>
<span class="title">Finish</span>
</div>
</div>

这是具有相同代码的 jsfiddle:http://jsfiddle.net/Misiu/40udkfov/3/

我需要修复文本对齐方式,理想情况下,文本应在圆圈下方居中,每行一个字。

更新:

这是显示当前结果和预期结果的图像:

enter image description here

http://jsfiddle.net/Misiu/40udkfov/9/

更新 2

基于@dippas greate 答案的最终版本:

http://jsfiddle.net/Misiu/40udkfov/12/

最佳答案

只需在 .progress .circle .title 中添加一个 white-space:pre 并增加单词之间的空格 width 这里 .progress .bar80px100px 或任何你喜欢的。见下面的片段

<删除>
var i = 1;
$('.progress .circle').removeClass().addClass('circle');
$('.progress .bar').removeClass().addClass('bar');
setInterval(function() {
$('.progress .circle:nth-of-type(' + i + ')').addClass('active');
$('.progress .circle:nth-of-type(' + (i - 1) + ')').removeClass('active').addClass('done');
$('.progress .circle:nth-of-type(' + (i - 1) + ') .label').html('&#10003;');
$('.progress .bar:nth-of-type(' + (i - 1) + ')').addClass('active');
$('.progress .bar:nth-of-type(' + (i - 2) + ')').removeClass('active').addClass('done');
i++;
if (i == 8) {
$('.progress .circle').removeClass().addClass('circle');
$('.progress .bar').removeClass().addClass('bar');
i = 1;
}
}, 1000);
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */

.progress {
width: 1000px;
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
}
.progress .circle,
.progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
}
.progress .bar {
position: relative;
width: 100px;
height: 6px;
margin: 0 -5px 17px -5px;
border-left: none;
border-right: none;
border-radius: 0;
top: -16px;
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 30px;
margin-left: -5px;
white-space:pre;
}
/* Done / Active */

.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<div class="progress">

<div class="circle done">
<span class="label">1</span>
<span class="title">Order</span>
</div>

<span class="bar done"></span>

<div class="circle done">
<span class="label">2</span>
<span class="title">Address</span>
</div>

<span class="bar half"></span>

<div class="circle active">
<span class="label">3</span>
<span class="title">Payment</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">4</span>
<span class="title">Review</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">5</span>
<span class="title">Finish</span>
</div>
</div>

<div class="progress">
<div class="circle done">
<span class="label">1</span>
<span class="title">Order informations</span>
</div>

<span class="bar done"></span>

<div class="circle">
<span class="label">4</span>
<span class="title">Order review</span>
</div>

<span class="bar"></span>

<div class="circle">
<span class="label">5</span>
<span class="title">Finish</span>
</div>
</div>

编辑根据评论回答:

添加:display:block 并在 .progress 中将 line-height:30px 更改为 line-height:18px .circle .title

.progress .bar 中将 top:-16px 更改为 top:16px

vertical-align:top 添加到您的 .progress .circle,.progress .bar

请记住 inline-block 默认为 vertical-align:baseline

var i = 1;
$('.progress .circle').removeClass().addClass('circle');
$('.progress .bar').removeClass().addClass('bar');
setInterval(function() {
$('.progress .circle:nth-of-type(' + i + ')').addClass('active');
$('.progress .circle:nth-of-type(' + (i - 1) + ')').removeClass('active').addClass('done');
$('.progress .circle:nth-of-type(' + (i - 1) + ') .label').html('&#10003;');
$('.progress .bar:nth-of-type(' + (i - 1) + ')').addClass('active');
$('.progress .bar:nth-of-type(' + (i - 2) + ')').removeClass('active').addClass('done');
i++;
if (i == 8) {
$('.progress .circle').removeClass().addClass('circle');
$('.progress .bar').removeClass().addClass('bar');
i = 1;
}
}, 1000);
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */

.progress {
width: 1000px;
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
}
.progress .circle,
.progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
vertical-align:top;
}
.progress .bar {
position: relative;
width: 80px;
height: 6px;
margin: 0 -5px 17px -5px;
border-left: none;
border-right: none;
border-radius: 0;
top:16px;

}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 18px;
margin:10px 0 0 -5px;
display: block
}
/* Done / Active */

.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="progress">
<div class="circle done"> <span class="label">1</span>
<span class="title">Order</span>

</div> <span class="bar done"></span>

<div class="circle done"> <span class="label">2</span>
<span class="title">Address</span>

</div> <span class="bar half"></span>

<div class="circle active"> <span class="label">3</span>
<span class="title">Payment</span>

</div> <span class="bar"></span>

<div class="circle"> <span class="label">4</span>
<span class="title">Review</span>

</div> <span class="bar"></span>

<div class="circle"> <span class="label">5</span>
<span class="title">Finish</span>

</div>
</div>
<div class="progress">
<div class="circle done"> <span class="label">1</span>
<span class="title">Order informations</span>

</div> <span class="bar done"></span>

<div class="circle"> <span class="label">4</span>
<span class="title">Order review</span>

</div> <span class="bar"></span>

<div class="circle"> <span class="label">5</span>
<span class="title">Finish</span>

</div>
</div>

关于html - 圆形台阶指示器台阶名称位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27964565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com