我想通过使用css使进度条看起来像下面的图像.我能为它做些什么? what i expected

我已经试着这么做了.我得到的是这个. what i have done

progress {
  border: 1.5px solid silver;
  border-radius: 0px;
  width: 170px;
  height: 18px;
}

progress::-webkit-progress-bar {
  background-color: whitesmoke;
  border-radius: 0px;
}

progress::-webkit-progress-value {
  background-color: cornflowerblue;
  border-radius: 0px;
}
<section class="prog">
  <p>Progress of today's class <progress value="2" max="5"></progress></p>
</section>

推荐答案

你可以在background中加stripes.
使用线性渐变和%#ececec色限制为1.5%的宽度,并添加白色作为填充 colored颜色 .

progress {
  border: 1.5px solid silver;
  border-radius: 0px;
  width: 170px;
  height: 18px;
}
progress::-webkit-progress-bar {
      background: linear-gradient(
      to right,
      white 10%,
      #ececec 11% 11.5%,
      white 11.5% 20%,
      #ececec 20% 21.5%,
      white 21.5% 30%,
      #ececec 31% 31.5%,
      white 31.5% 40%,
      #ececec 41% 41.5%,
      white 41.5% 50%,
      #ececec 51% 51.5%,
      white 51.5% 60%,
      #ececec 60% 51.5%,
      white 61.5% 70%,
      #ececec 70% 71.5%,
       white 71.5% 80%,
      #ececec 80% 81.5%,
       white 81.5% 90%,
      #ececec 90% 91.5%,
       white 10%
    );
  border-radius: 0px;
}
progress::-webkit-progress-value {
  background-color: cornflowerblue;
  border-radius: 0px;
}
<section class="prog">   
  <p>Progress of today's class 
   <progress value="2" max="5"></progress>
  </p>
</section>

UPDATE:
As @Afif mentioned repeating-linear-gradient(), this method is a more concise & compact way to do the same thing as above. It is also supported in almost every browser.
progress {
  border: 1.5px solid silver;
  border-radius: 0px;
  width: 170px;
  height: 18px;
}
progress::-webkit-progress-bar {
  background: repeating-linear-gradient(90Deg, white, white 9%, #ececec 10%);
  border-radius: 0px;
}
progress::-webkit-progress-value {
  background-color: cornflowerblue;
  border-radius: 0px;
}
<section class="prog">   
  <p>Progress of today's class 
   <progress value="2" max="5"></progress>
  </p>
</section>

Html相关问答推荐

为什么html复选框总是具有只读属性?

角|将动态html属性添加到子组件

如何正确使用counter()、counter—increment()和counter—reset()嵌套标题?

Angular 分量被循环

调整一组IMG的大小以适应容器DIV

如何使用CSS在NSAttributedString中为HTML文本中的图像制作覆盖图

如何在HTML中适当地为单选按钮网格添加标签?

将精选选项的价格合并为一个价格HTML、PHP和JQuery

如何使链接组件内的内容不重新路由Next.js13

使用 Thymeleaf 将图像水平居中

如何从 div 内的属性中提取 href 和文本

文本不显示在 div 下方

为什么盒子不在div中显示?

CSS Grid 布局:1 大图和 3 小图

绝对类在另一个绝对类之上

在包含 html 标签的字符串的子字符串中应用不同的样式

在身体外部创建 tanget 45° div

防止按钮溢出到新行

需要禁用聚焦输入的工具提示(jquery)

另一个 flex 元素之间的 CSS 空间