CSS box-shadow z-index 或更改顺序

问题描述

我想用 Box-shadow 实现如下效果

enter image description here

但我正在实现以下目标:

enter image description here

我正在使用以下代码

<div class="progress-container"></div>
.progress-container {
  width: 100%;
  height: 11px;
  position: relative;
  background: #EAEFF5;
  border-radius: 5px;
  z-index: -1;

  Box-shadow: 
    80px 0 0  #0AA693 inset,500px 0 0 #FF7800 inset;
}

您可以找到我的代码here

感谢您的帮助。

解决方法

我认为使用框阴影无法做到这一点,因为您无法为 x 位置设置起点。

.progress-container {
  width: 100%;
  height: 11px;
  position: relative;
  background: #EAEFF5;
  border-radius: 5px;
}

.progress-container::before,.progress-container::after {
  content: "";
  position: absolute;
  border-radius: inherit;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.progress-container::before {
  background-color: #FF7800;
  width: 500px;
}

.progress-container::after {
  background-color: #0AA693;
  width: 80px;
}
<div class="progress-container">
</div>

,

只需增加X轴,在初始faze中将其设置为80px,80px 0 0 #0AA693 inset,这是阴影,第一个数字是X轴,第二个数字是Y轴,第三个数字是模糊。因此,将其更改为类似 400px 0 0 #0aa693 的内容,这就是解决方案。

.progress-container {
  width: 100%;
  height: 30px;
  position: relative;
  background: #eaeff5;
  border-radius: 3px;
  z-index: -1;

  box-shadow: 400px 0 0 #0aa693 inset,500px 0 0 #ff7800 inset;
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...