亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 window.print() 打印時背景顏色消失

使用 window.print() 打印時背景顏色消失

呼如林 2023-12-19 20:50:24
我正在嘗試使用?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 中的問題!



查看完整回答
反對 回復 2023-12-19
  • 1 回答
  • 0 關注
  • 552 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號