如何在我的项目页面上放置打印链接/按钮来打印信息?
问题描述:
我的应用程序(学生注册)使用 Rails,我需要一个打印链接/按钮来打印一些学生的信息.请问我该怎么办?
I am using Rails for my application(student register) and i need a print link/button to print out some student's information. Please what do I do?
答
您可以使用此标签制作打印链接.
You can use this tag to make a print link.
<%= link_to 'print', 'your_link_here', :onclick => 'window.print();return false;'%>
现在,如果要打印特定部分,可以使用 css 媒体类型
Now, if you want to print a specific section, you can use media types of css
/*This css will only works when you print*/
@media print {
body {
background: #FFF;
}
}