显示内联成员
我正在尝试水平显示我的事件/索引,但我似乎无法让它工作。 Index.html.erb
<ul>
<% @events.each do |event| %>
<li>
<h3>
<%= link_to event.name, event.flyer.url %>
<%= event.event_date %> <br/>
<% if event.preview.exists? then %>
</h3>
<%= image_tag event.preview.url(:small) %>
<% end %> <br/>
<%= event.description %> <br/>
<%= link_to 'Show', event %>
<%= link_to 'Edit', edit_event_path(event) %>
<%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => 'delete' %>
</li>
<% end %>
</ul>
<%= link_to 'New Event', new_event_path %>
风格
<style type="text/css">
ul
{
margin: 0 auto;
padding: 0;
list-style-type: none;
text-align: center;
}
ul li { display: inline; }
</style>
I'm trying to display my events/index horizontally but I can't seem to get it to work.
Index.html.erb
<ul>
<% @events.each do |event| %>
<li>
<h3>
<%= link_to event.name, event.flyer.url %>
<%= event.event_date %> <br/>
<% if event.preview.exists? then %>
</h3>
<%= image_tag event.preview.url(:small) %>
<% end %> <br/>
<%= event.description %> <br/>
<%= link_to 'Show', event %>
<%= link_to 'Edit', edit_event_path(event) %>
<%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => 'delete' %>
</li>
<% end %>
</ul>
<%= link_to 'New Event', new_event_path %>
style
<style type="text/css">
ul
{
margin: 0 auto;
padding: 0;
list-style-type: none;
text-align: center;
}
ul li { display: inline; }
</style>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的问题是
display:inline
调整其宽度和高度以适应其内部的元素。要水平显示元素,您必须固定项目的高度和宽度。
试试这个
The problem here is
display:inline
adjusts its width and height to the elements inside it.For displaying elements horizontally you have to fix item's height and width.
Try this