我的代码如下所示:
xyz.css
.q-order-info-container {
width: 100vw;
height: 100vh;
}
.q-order-info-container .status-parent {
position: relative;
top: 10px;
margin: 0 10px 0 10px;
height: 100px;
padding: 0;
}
.q-order-info-container .status-parent .status-background {
position: absolute;
top: 0;
display: flex;
align-items: center;
width: 100%;
height: 100%;
background-color: transparent;
}
.q-order-info-container .status-parent .status-background .status-bar-default {
width: calc(100% - 40px);
height: 2px;
margin-left: 20px;
background-color: gray;
}
.q-order-info-container .status-parent .status-background .status-bar-one-active {
width: 50%;
height: 2px;
margin-left: 10px;
background-color: #6900B2;
}
.q-order-info-container .status-parent .status-background .status-bar-two-active {
width: calc(100% - 40px);
height: 2px;
margin-left: 20px;
background-color: #6900B2;
}
.q-order-info-container .status-parent .q-status-container {
display: flex;
flex-direction: row;
/* margin: 10px 10px 0 10px; */
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
height: 100%;
}
.q-order-info-container .status-parent .q-status-container .q-status-one {
display: flex;
flex: 1;
align-items: center;
padding-left: 10px;
background-color: white;
}
.q-order-info-container .status-parent .q-status-container .q-status-one .q-status-text {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
color: white;
align-items: center;
border-radius: 15px;
background-color: #6900B2;
}
.q-order-info-container .status-parent .q-status-container .q-status-two {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
background-color: white;
}
.q-order-info-container .status-parent .q-status-container .q-status-two .q-status-text {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
color: white;
align-items: center;
border-radius: 15px;
background-color: #6900B2;
}
.q-order-info-container .status-parent .q-status-container .q-status-three {
display: flex;
flex: 1;
align-items: center;
justify-content: flex-end;
background-color: white;
padding-right: 10px;
}
.q-order-info-container .status-parent .q-status-container .q-status-three .q-status-text {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
color: white;
align-items: center;
border-radius: 15px;
background-color: #6900B2;
}
xyz.html
<div class="q-order-info-container">
<div class="status-parent" ng-model="order" ng-switch="order.order_status">
<div class="q-status-container">
<div class="q-status-one">
<div class="q-status-text"> 1</div>
</div>
<div class="q-status-two">
<div class="q-status-text"> 2</div>
</div>
<div class="q-status-three">
<div class="q-status-text"> 3</div>
</div>
</div>
<div class="status-background">
<div class="status-bar-default">
</div>
<div ng-switch-when="1" class="status-bar-one-active"></div>
<div ng-switch-when="2" class="status-bar-two-active"></div>
</div>
</div>
</div>
现在我得到的输出是
但是,我希望条带在其他东西的背景下
答案 0 :(得分:2)
这是一个有效的演示:
.q-order-info-container {
width: 100vw;
height: 100vh;
}
.q-order-info-container .status-parent {
position: relative;
top: 10px;
margin: 0 10px 0 10px;
height: 100px;
padding: 0;
}
.q-order-info-container .status-parent .status-background {
position: absolute;
top: 0;
display: flex;
align-items: center;
width: 100%;
height: 100%;
background-color: transparent;
}
.q-order-info-container .status-parent .status-background .status-bar-default {
width: calc(100% - 40px);
height: 2px;
margin-left: 20px;
background-color: gray;
}
.q-order-info-container .status-parent .status-background .status-bar-one-active {
width: 50%;
height: 2px;
margin-left: 10px;
background-color: #6900B2;
}
.q-order-info-container .status-parent .status-background .status-bar-two-active {
width: calc(100% - 40px);
height: 2px;
margin-left: 20px;
background-color: #6900B2;
}
.q-order-info-container .status-parent .q-status-container {
display: flex;
flex-direction: row;
/* margin: 10px 10px 0 10px; */
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
height: 100%;
}
.q-order-info-container .status-parent .q-status-container .q-status-one {
display: flex;
flex: 1;
align-items: center;
padding-left: 10px;
background-color: white;
}
.q-order-info-container .status-parent .q-status-container .q-status-one .q-status-text {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
color: white;
align-items: center;
border-radius: 15px;
background-color: #6900B2;
z-index: 10;
}
.q-order-info-container .status-parent .q-status-container .q-status-two {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
background-color: white;
}
.q-order-info-container .status-parent .q-status-container .q-status-two .q-status-text {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
color: white;
align-items: center;
border-radius: 15px;
background-color: #6900B2;
z-index: 10;
}
.q-order-info-container .status-parent .q-status-container .q-status-three {
display: flex;
flex: 1;
align-items: center;
justify-content: flex-end;
background-color: white;
padding-right: 10px;
}
.q-order-info-container .status-parent .q-status-container .q-status-three .q-status-text {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
color: white;
align-items: center;
border-radius: 15px;
background-color: #6900B2;
z-index: 10;
}
<div class="q-order-info-container">
<div class="status-parent" ng-model="order" ng-switch="order.order_status">
<div class="q-status-container">
<div class="q-status-one">
<div class="q-status-text"> 1</div>
</div>
<div class="q-status-two">
<div class="q-status-text"> 2</div>
</div>
<div class="q-status-three">
<div class="q-status-text"> 3</div>
</div>
</div>
<div class="status-background">
<div class="status-bar-default">
</div>
<div ng-switch-when="1" class="status-bar-one-active"></div>
<div ng-switch-when="2" class="status-bar-two-active"></div>
</div>
</div>
</div>
您必须更改号码的z-index
。
希望这有帮助!
答案 1 :(得分:1)
您需要z-index属性:
.q-order-info-container .status-parent .q-status-container .q-status-two .q-status-text {
z-index:1
}
同样的事情:
.q-order-info-container .status-parent .q-status-container .q-status-one .q-status-text {
z-index: 1
}
.q-order-info-container .status-parent .q-status-container .q-status-three .q-status-text {
z-index:1
}