【发布时间】:2026-02-10 15:25:01
【问题描述】:
在我的 index.html 中,我创建了以下 div,它位于 center 标记内。
<div class="container">
<div class="bar">
<span class="bar-fill"></span>
</div>
</div>
页面上如下所示:[进度条图片]1
我希望蓝色条位于此容器的左侧。
下面是我的 CSS:
/* Progress Bar */
.container {
width: 400px;
}
.bar {
width: 100%;
background: #eee;
padding: 3px;
border-radius: 3px;
box-shadow: inset 0px 1px 3px rgba(0,0,0,.2);
}
.bar-fill {
height: 20px;
display: block;
background: cornflowerblue;
width: 80%;
border-radius: 3px;
}
再一次,我希望将蓝色条(标有条形或条形填充的 div)定位在容器内的左侧。
谢谢。
【问题讨论】:
-
请不要使用已弃用的
<center>标签。当您删除它时,问题可能会消失 -
啊,
<center>标签,我的老朋友。 -
尝试将 float:left 添加到 .bar-fill
-
那么在不使用
标签的情况下,将所有内容居中的最佳方法是什么? -
将包含元素的内容的“左”和“右”边距设置为“自动”
标签: javascript html css progress