2017-01-06 23 views
3

打印刪除邊框你好,我試圖從我的表中刪除邊框時使用CSS用戶點擊打印按鈕(window.print),但它留總是打印頁如何我可以從表而使用CSS @media打印

這是我的CSS代碼:

@media print{ 

    body * {visibility: hidden; 


    } 

    table { 
     border:solid; white !important; 
     border-width:1px 0 0 1px !important; 
     border-bottom-style: none; 
    } 
    th, td{ 
     border:solid; white !important; 
     border-width:0 1px 1px 0 !important; 
     border-bottom-style: none; 
    } 
} 

這個CSS給了我這樣的結果:

enter image description here

臺停留的底部邊框顯示我如何可以將其刪除感謝ü

+0

首先,請嘗試使用'邊界:純白重要;'(沒有';! '堅實後')。 –

+0

你能發佈你的html代碼嗎? –

+0

嘗試'border-bottom:none;' –

回答

2

最後這個解決方案爲我工作:

@media print { 

    * { 
     color: #000;  
     background-color: #fff; 
     @include box-shadow(none); 
     @include text-shadow(none); 
    } 
} 
4

你可以在你的CSS3 @media規則使用:

border-bottom: none; 

border: solid white !important; 

使用​​可能影響你表的佈局打印時(取決於如果你是是否使用帶有默認值的box-sizing)。

下面的例子:


<!DOCTYPE html> 
<html> 
<head> 
    <title></title> 
    <meta charset="utf-8" /> 
    <style> 
     table { 
      /* just an example */ 
      border: solid red; 
      border-width: 1px 0 0 1px !important; 
      border-bottom-style: none; 
     } 

     @media print { 

      table { 
       border: solid white !important; 
       border-width: 1px 0 0 1px !important; 
       border-bottom-style: none; 
      } 

      th, td { 
       border: solid white !important; 
       border-width: 0 1px 1px 0 !important; 
       border-bottom-style: none; 
      } 
     } 
    </style> 
</head> 
<body> 
    <table style="width:100%"> 
     <tr> 
      <th>Firstname</th> 
      <th>Lastname</th> 
      <th>Age</th> 
     </tr> 
     <tr> 
      <td>Jill</td> 
      <td>Smith</td> 
      <td>50</td> 
     </tr> 
     <tr> 
      <td>Eve</td> 
      <td>Jackson</td> 
      <td>94</td> 
     </tr> 
    </table> 
</body> 
</html>