这是一个Ruby on Rails应用程序,我无法将主体放在页面顶部.截图:
我不知道为什么会发生这种情况,因为我已经正确设置了所有属性.这是整个应用程序的来源. 我的看法:
<div id="header-wrap">
<div id="header">
<h1>Blog</h1>
</div>
</div>
<div id="wrapper">
<div id="posts">
<% @posts.each do|post| %>
<div id="post">
<h2><%= post.title %></h2>
<%= simple_format post.body %>
<small>
<%= link_to 'Edit', edit_post_path(post) %> |
<%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %>
</small>
</div>
<% end %>
</div>
<br>
<%= link_to 'New Post', new_post_path %>
</div>
Run Code Online (Sandbox Code Playgroud)
我的CSS(注释掉的CSS是我通过改变标题包装和包装元素的位置来修复问题的黑客攻击):
/*
* This is a manifest file that'll be compiled into application.css, which will …Run Code Online (Sandbox Code Playgroud) 编辑:这已在下面得到解答.
我想有一个HTML表,每行之间有隐藏的行,有关顶级行的更多信息.单击第一列中的展开/折叠图像链接时,隐藏行的可见性将从display:none切换; 显示:table-row;.我有一段时间没有编写JavaScript,需要能够在JavaScript中严格执行此操作,并且不能使用jQuery toggle()方法.
我如何使用JavaScript来查找带有class ="parentRow"的class ="subRow"的兄弟,该按钮位于表中,然后切换该兄弟行的可见性?
<table style="width:50%">
<caption>Test Table</caption>
<thead>
<tr align="center">
<th><span class="offscreen">State Icon</span></th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
</tr>
</thead>
<tbody>
<tr align="center" class="parentRow">
<td><a href="#" onclick="toggleRow();"><img alt="Expand row" height="20px;" src="expand.png"></a></td>
<td>test cell</td>
<td>test cell</td>
<td>test cell</td>
<td>test cell</td>
</tr>
<tr style="display: none;" class="subRow">
<td colspan="5"><p>Lorem ipsum dolor sit amet...</p></td>
</tr>
....
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
.offscreen {
position: absolute;
left: -1000px;
top: 0px;
overflow:hidden;
width:0;
}
.subRow {
background-color: #CFCFCF;
} …Run Code Online (Sandbox Code Playgroud)