我只是在搞乱我正在玩的应用程序的格式。它看起来像这样:
我想使用表来获取它,以便“sd”下的所有内容都将紧挨着它。像这样:
我怎么能这样做......使用表格?
这是我目前的代码:
<div class ="individ_post">
<table>
<tr>
<td>
<p>sd</p>
<p>sd</p>
<p>sd</p>
<p>sd</p>
<p>sd</p>
<p>sd</p>
<p>sd</p>
</td>
</tr>
<% @posts.each do |post| %>
<tr>
<td id="voting_deletion_table">
<div id="post_voting_and_deleting">
<div class="vote_score"><%= post.reputation_value_for(:votes).to_i %></div>
<br />
<% if user_is_logged_in? %>
<%= button_to "+", vote_group_post_path(@group, post, type: "up"), method: "post" %>
<%= button_to "-", vote_group_post_path(@group, post, type: "down"), method: "post" %>
<% end %>
</div>
<% if user_is_logged_in? && current_user.id == post.user_id %>
<td><%= button_to 'x', [@group, post], method: :delete, confirm: 'Are you sure?' %></td>
<% end %>
</td>
<td id="previow_of_post_table">
<div class ="preview_of_post">
<% if post.image_url %>
<%= image_tag post.image_url(:thumb).to_s %>
<% elsif post.link %>
<%= extract_content_from_url(post.link) %>
<% end %>
</div>
</td>
<td id="comments_table">
<div class ="post_author">@<%= post.user.username%>:</div> <div class ="post_title"><%= post.title %></div>
<% post.comments.each do |comment| %>
<div class ="post_comments">
> <span class="comment_username">@<%= comment.user.username %></span>:<%= comment.body %>
</div>
<% end %>
<% if user_is_logged_in? %>
<%= form_for([post.group, post, post.comments.build]) do |f| %>
<p>
<%= f.label :comment %><br />
<%= f.text_area :body, :rows => 3, :cols => 55 %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
<% end %>
</td>
</table>
</div>
<hr />
<br />
<% end %>
谢谢!
答案 0 :(得分:0)
使用div进行CSS定位,类似于位置:相对(this page上的第2步)?
答案 1 :(得分:0)
不要将TABLES用于布局。使用FLOATS。
表格用于表格数据,人们在1999年陷入困境。
结构将是这样的:
<div class="wrapper">
<div class="labels">
sd ... sd ...
</div>
<div class="controls">
...buttons...
</div>
<div class="formpanel">
...your form elements ....
</div>
</div>
设置元素的宽度,并使用float:left
作为内部DIV元素。