我使用以下 css 代码将圆角应用于我的表格:
#rounded-corner
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 45px;
width: 480px;
text-align: left;
border-collapse: collapse;
}
#rounded-corner thead th.rounded-company
{
background: #b9c9fe url(/assets/left.png) right -1px no-repeat;
width:100%;
height:auto;
}
#rounded-corner thead th.rounded-q4
{
background: #b9c9fe url(/assets/right.png) right -1px no-repeat;
}
#rounded-corner th
{
padding: 8px;
font-weight: normal;
font-size: 13px;
color: #039;
background: #b9c9fe;
}
#rounded-corner td
{
padding: 8px;
background: #e8edff;
border-top: 1px solid #fff;
color: #669;
}
#rounded-corner tfoot td.rounded-foot-left
{
background: #e8edff url(/assets/botleft.png) left bottom no-repeat;
}
#rounded-corner tfoot td.rounded-foot-right
{
background: #e8edff url(/assets/botright.png) right bottom no-repeat;
}
#rounded-corner tbody tr:hover td
{
background: #d0dafd;
}
我可以完美地获得桌子各部分的颜色,但我无法获得圆角。我已将图像放在 /assets 文件夹以及 /assets/images/ 文件夹中。
以下是 index.html.erb 代码。
<!DOCTYPE html>
<html>
<head>
<title>List of Posts</title>
<meta charset="UTF-8">
<%= stylesheet_link_tag "posts.css.scss" %>
<h1 id = header align=center>Listing Posts</h1>
</head>
<div align=center><%= link_to 'New Post', new_post_path %></div>
<div align=center>
<table id="rounded-corner">
<tr>
<th>Title</th>
<th>Text</th>
<th colspan="3"></th>
</tr>
<% @post.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.text %></td>
<td><%= link_to 'Show', post_path(post),:class =>'links' %></td>
<td><%= link_to 'Edit', edit_post_path(post),:class =>'links' %></td>
<td><%= link_to 'Destroy', post_path(post), method: :delete, data: { confirm: 'Are you sure ?' },:class =>'links' %></td>
</tr>
<% end %>
</table>
</div>
</html>