twitter-bootstrap 使用 Bootstrap 将按钮设为 PDF 文件的链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16763267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Make button a link to PDF file with Bootstrap
提问by mcadamsjustin
I'd like to link a pdf to a button using the bootstrap framework in Rails. For example the button would say download now and link to the PDF. I'm not concerned on how the PDF opens, just that it links to it.
我想使用 Rails 中的引导程序框架将 pdf 链接到按钮。例如,按钮会显示立即下载并链接到 PDF。我不关心 PDF 如何打开,只关心它链接到它。
In the Bootstrap documentation it says to use only the <a>tag and it doesn't mention anything about the <%= link_to %>tag. This is what's listed in the Bootstrap doc's <a class="btn btn-large btn-danger" href="#">Download Now</a>, where "Download Now" is the text show on the button.
在 Bootstrap 文档中,它说只使用<a>标签,没有提到任何关于<%= link_to %>标签的内容。这是 Bootstrap 文档中列出的内容<a class="btn btn-large btn-danger" href="#">Download Now</a>,其中“立即下载”是按钮上显示的文本。
Any help is appreciated.
任何帮助表示赞赏。
回答by Bogdan Rybak
You can specify class as one of the arguments of link_to
您可以将 class 指定为 link_to
<%= link_to "Download Now", '/path/to/file/or/path_method', :class => "btn btn-large btn-danger" %>
or
或者
<%= link_to '/path/to/file/or/path_method', :class => "btn btn-large btn-danger" do %>
Download Now
<% end %>

