Printing Data inside a div

谁说胖子不能爱 提交于 2019-12-12 02:28:25

问题


I have a lot of DIVs having some data in my web page & I want to print a data of a specific div by using "window.print()" without opening any popup. What should I do?


回答1:


You must use CSS Media Types like this:

    @media print {
        #printable {
            display:block;
            overflow: visible;
        }

        #nonprintable {
            display:none;
        }
    }
    @media screen {
        body, table, tr, td { font:12px Arial, Helvetica, sans-serif; }
        .divStyles {
            width:850px;
            height:150px;
            border: 1px solid #000;
            background-color: #ccc;
            padding: 15px;
        }
    }

I have created an example for you, see a demo: http://jsfiddle.net/rathoreahsan/Vuw6D/3/



来源:https://stackoverflow.com/questions/6454046/printing-data-inside-a-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!