这是因为浏览器不打印背景(使用默认设置),但它打印边框,我们可以使用它!试试这个https://stackoverflow.com/a/46216102/8601222
评论后编辑
您可以为@media print 添加这个(我的LESS-CSS代码):
@media print {
.progress {
position: relative;
&:before {
display: block;
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 0;
border-bottom: @line-height-computed solid @gray-lighter;
}
&-bar {
position: absolute;
top: 0;
bottom: 0;
left: 0;
z-index: 1;
border-bottom: @line-height-computed solid @brand-primary;
&-success {
border-bottom-color: @brand-success;
}
&-info {
border-bottom-color: @brand-info;
}
&-warning {
border-bottom-color: @brand-warning;
}
&-danger {
border-bottom-color: @brand-danger;
}
}
}
}
编译的 CSS(带有我的变量):
@media print {
.progress {
position: relative;
}
.progress:before {
display: block;
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 0;
border-bottom: 2rem solid #eeeeee;
}
.progress-bar {
position: absolute;
top: 0;
bottom: 0;
left: 0;
z-index: 1;
border-bottom: 2rem solid #337ab7;
}
.progress-bar-success {
border-bottom-color: #67c600;
}
.progress-bar-info {
border-bottom-color: #5bc0de;
}
.progress-bar-warning {
border-bottom-color: #f0a839;
}
.progress-bar-danger {
border-bottom-color: #ee2f31;
}
}
像 Bootstrap 3 中的魅力一样工作。