2013-04-24 90 views
0

我創建了一個鏈接到我的html頁面的打印樣式表。對字體,顏色等的更改可以在打印版本中使用,但我無法在打印版本中更改我的div的大小。例如,如果我的網頁上有一個300px X 300px的內容div,如果我更改打印版本中的尺寸,它將不會更改它。 爲了找出問題的根源,我使用了inspect元素來查看一個css是否覆蓋了我的打印頁面。我發現內容div寬度是由身體寬度控制的。所以我試着改變打印樣式表中的內容高度和body div。這沒有用。我也嘗試爲主css和打印css創建單獨的樣式表。這沒有用。有沒有另一種方法可以解決這個問題...類似於斷點的東西也許,但對於HTML?我怎樣才能找出什麼CSS重寫我的樣式表中的CSS?

HTML:

<!DOCTYPE html> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <!--- TITLE - FROM SPECIFIC TO GENERAL ---> 
    <title>Page</title> 
    <cfinclude template="/assets2011/webfonts/comment.htm" /> 
    <link rel="stylesheet" type="text/css"  href="/assets2011/MyFontsWebfontsOrderM2845569_css.css" /> 
    <link rel="stylesheet" type="text/css" href="/assets2011/css/global.css" /> 
    <link href="print.css" type="text/css" rel="stylesheet" media="print"/> 
    <style> 

    body{ 
    width: 8700px; 
    height:2000px; 
    overflow: hidden; 
    } 
    #section{ 
    width: 8000px; 
    float: left; 
     height: 1000; 
     z-index: 1; 
     } 
     #content{ 
     width: 1000px; height:300px; margin-top: 10px; margin-left: 50px; overflow: auto; 
     } 
     .navbarLeft{ 
     height: 700px; 
     width: 40px; 
     top:0; 
    z-index: 2; 
     position:absolute; 
     background-position: 50% 30%; 
     background-image: url(navL.png); 
    background-repeat: no-repeat; 
    opacity: 0.05; 
     } 
     .navbarLeft:hover{ 
     opacity: 0.5; 
     } 
     .navbarRight{ 
     height: 700px; 
     width: 40px; 
    top: 0; 
    z-index: 2; 
    position: absolute; 
    background-position: 50% 30%; 
    background-image: url(navR.png); 
    background-repeat: no-repeat; 
    opacity: 0.05; 
    left: 2013px; 
    } 
    .navbarRight:hover{ 
     opacity: 0.5; 
    } 
    table,tr,td { 
    border:1px solid black; 
    } 

    </style> 

    </head> 
     <body> 
     <!--Factor 1--> 
    <div class="section" id="factor1"> 
    <div id="content"> 
    <!--Begin Content--> 
      <p>textiyiuypilkhjkujp;mjl;juipoupoj;hikhiyuiuj</p> 
     </div> 
    <!--End Content--> 

     <!-- Navigation --> 
    <ul class="nav"> 
    <a href="#factor2"><div class= "navbarLeft" id="menu" style="left: 755px;"></div></a> 
     </ul> 
     </div> 
     <!--End Factor 1--> 


    <!--Factor 2--> 
    <div class="section" id="factor2"> 
    <div id="content"> 
     <p>text2khlikhlkj;ljlji0piomloj;lkjoippm,klikp</p> 
    </div> 
    <ul class="nav"> 
    <a href="#factor1"><div class= "navbarRight" id="menu" style="left: 2005px;"></div> 
     </a> 
    <a href="#factor3"><div class= "navbarLeft" id="menu" style="left: 2755px;"></div></a> 
    </ul> 
    </div> 
    <!--End Factor 2--> 

    <!--JavaScript--> 
    <script type="text/javascript" 
       src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
    <script type="text/javascript" src="../newUI/jquery.easing.1.3.js"></script> 
    <script type="text/javascript"> 
      $(function() { 
       $('ul.nav a').bind('click',function(event){ 
        var $anchor = $(this); 
        $('html, body').stop().animate({ 
         scrollLeft: $($anchor.attr('href')).offset().left 
        }, 1000); 
        event.preventDefault(); 
       }); 
      }); 
     </script> 
     </body> 
    </html> 

CSS打印樣式表:

 body{ 
     width: 1000px; 
     } 

    #section, .navbarLeft, .navbarRight{ 
    display:none; 
    } 

    #content{ 
     font-size: 110px; 
     overflow:visible; 
     height: 1000px; 
     page-break-after: always; 
     margin-top:10px; 
     margin-left:50px; 
    } 

    p a:after { 
    content: " (" attr(href) ")"; 
    font-size: 50%; 
    } 

回答

0

我發現Chrome瀏覽器開發者工具是夢幻般的調試CSS問題。

在Chrome中打開該頁面並點擊F12

enter image description here

放眼元素選項卡上的權利,你會看到所有正在應用到左側所選HTML元素的CSS。

您可以在工具箱中就地編輯CSS,它會立即用您的更改更新瀏覽器窗口。

有關工具的更多信息可以在這裏找到:https://developers.google.com/chrome-developer-tools/