我正在嘗試使用?window.print();?在 anglat 中打印頁面,一切正常,所有其他 css 都正常工作,唯一的問題是背景顏色沒有顯示在可打印文檔中,我附上了一個 StackBlitz 示例,所以:以前有人遇到過這個問題嗎? ,如果是的話解決辦法是什么,謝謝。StackBlitz 示例來自此處可打印文件 HTML :<div class="page-container"><div class="title-container">Invoice Title</div><div class="body-container">? This is what I'm going to print, everything works fine , but the background color never changes , no matter what i add to css file</div></div>頁面的CSS:.page-container{? width: 100%;? background-color : rgb(216, 23, 23);? // as you can see , background not working?}.title-container{? font-size: 24px;? width: 100%;? display: flex;? flex-direction: row;? justify-content: center;? padding-bottom: 20px;? border: 2px blueviolet solid;? color: rgb(228, 0, 228);? background-color : rgb(221, 0, 0) !important;// not working also}.body-container{? background : #000; // not working?}結果 :
1 回答

狐的傳說
TA貢獻1804條經驗 獲得超3個贊
在 css 頁面中添加 -webkit-print-color-adjust: exact;
解決了 chrom 中的問題,color-adjust: exact;
解決了 mozilla firefox 中的問題!
- 1 回答
- 0 關注
- 552 瀏覽
添加回答
舉報
0/150
提交
取消