[英]Rails: Displaying Users on Index Page
我試圖通過CSS在我的項目中為“用戶索引”頁面設置樣式,以便在用戶注冊並添加到數據庫時,“用戶照片”和“文本”以“網格”方式顯示。 我的用戶/index.html.erb如下:
<%= link_to user do %>
<%= image_tag user.photo.url(:small) %>
<% end %><br />
<%= user.first_name %>
<%= user.last_name %><br />
<%= user.city %><br />
<%= user.country %><br /><br />
<% if current_user and current_user.admin %>
<%= link_to image_tag("edit.png", {:alt => 'Edit User'}), edit_user_path(user), :method => :get %>
<%= link_to image_tag("delete.png", {:alt => 'Delete User'}), user, method: :delete, data: { confirm: 'Are you sure you want to delete this User?' } %><br /><br />
<% end %>
我想進行設置,以使“用戶照片”顯示在名稱,城市和國家/地區上方,而下一個“用戶”顯示在“等等”旁邊。“編輯”和“刪除”將通過“管理員”過濾器顯示。 我在需要的地方添加了一些休息時間。 我已經嘗試過各種浮標,相對位置等,但似乎無法正常使用...有什么想法嗎?
非常感謝!
您可以根據需要使用Bootstrap或任何其他網格框架。
我使用了引導程序來演示所需的布局。 希望這可以幫助
<div class="container">
<div class="row">
<div class="span2">
...
</div>
<div class="span2">
...
</div>
</div>
</div>
見小提琴
更新:
見小提琴
您所需要做的就是給框指定一個寬度並將其浮動,以使其顯示在網格布局中。
.box {
width: 140px;
float: left;
background: #f5f5f5;
border: 1px solid #e1e1e1;
padding: 2px;
border-radius: 3px;
margin: 10px 5px 5px 10px;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.