html - 有空格时进度条标签显示不正确

标签 html css

我有一个进度条:

<div class="progress">
    <div class="circle done">
            <span class="label">1</span>
            <span class="title">One Two Three</span>
    </div>
    <span class="bar done"></span>
    <div class="circle done">
            <span class="label">2</span>
            <span class="title">OneTwoThree</span>
    </div>
    <span class="bar half"></span>
    <div class="circle active">
            <span class="label">3</span>
            <span class="title">OneTwoThreeFour</span>
    </div>
    <span class="bar"></span>
    <div class="circle">
            <span class="label">4</span>
            <span class="title">Five Six Seven</span>
    </div>

</div>

使用以下 CSS

 *, *:after, *:before {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Open Sans";
}

    .progress {
    width: 1000px;
    margin: 20px auto;
    text-align: center;
}
.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;
    top: -33px;
    margin-left: -5px;
    margin-right: -5px;
    border-left: none;
    border-right: none;
    border-radius: 0;
}
.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;
    }

问题出在第一个节点和最后一个节点上,因为它们的标题中有空格。我该如何解决。我尝试调整 css 但到目前为止没有成功

最佳答案

将 nowrap 添加到标题元素。它强制所有单词在一行中。

.progress .circle .title {
    white-space: nowrap;
}

关于html - 有空格时进度条标签显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52192470/

相关文章:

html - 行和列之间的相同空间 bootstrap

html - 定位特定元素,如果它包含另一个仅使用 CSS 的元素

html - Twitter 嵌入式使内容下降

javascript - 如何在 Angular Material 中固定 mat-select-panel 的位置

CSS:如何制作带有 repeat-x 背景和提示的 !100% 标题

javascript - 并排水平输入范围和垂直输入范围

html - 模式在 Safari 以外的所有浏览器中打开

html - 通过“所有 : unset“breaks inline SVG”重置 CSS

html - HTML 文件中的图像非常模糊且没有聚焦

jquery - 并排的盒子;一种静态宽度,一种可变宽度,底部垂直对齐