asd*_*kag 5 css ruby ruby-on-rails
当我打印报告时
<td><%= link_to (index + 1).to_s, data_report_path(datum.id), target: "_blank" %></td>
Run Code Online (Sandbox Code Playgroud)
在打印视图中,我希望显示索引,说"1".但是当我打印时,它显示"1(/ report_data/1/report)"
我在铁轨上使用红宝石.
我试过的:
1.我在app/assets/stylesheets/application.css.scss中添加了以下代码
@media print {
.noprint {display:none !important;}
a:link:after, a:visited:after {
display: none;
content: "";
}
}
Run Code Online (Sandbox Code Playgroud)
2 .add class:'no-print'所以代码变成了
link_to (index + 1).to_s, data_report_path(datum.id), class:'no-print',target: "_blank"
Run Code Online (Sandbox Code Playgroud)
但都不起作用.
我应该在哪里添加&我应该添加什么代码以在打印时隐藏此链接?
刚刚测试过fiddle,它在打印视图中显示为普通文本,但在您使用时bootstrap或foundation按照您的描述显示.因为你没有使用bootstrap所以我认为其他一些插件正在锚点上应用这种打印样式
a[href]::after {
content: " (" attr(href) ")"
}
Run Code Online (Sandbox Code Playgroud)
因此,您需要在自定义css文件中覆盖此样式.你可以做到
@media print {
a[href]:after {
content: none !important;
// use important only if you are not able to override it by normal styling
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1080 次 |
| 最近记录: |