我需要将桌子设计成圆角。
我只是在看看如何最好地去做:
通常,当我将 div 样式设置为圆角时,我会使用 2 个 div,顶部和底部带有空注释,并对其应用尺寸和背景图像 CSS。
然而,表格有内部边框,所以我必须仔细对齐角落 bg 图像中的垂直线,以匹配真正的单元格边框。
到目前为止,这清楚吗?
所以我想知道其他人会如何处理这个问题。我认为我能做的最好的事情就是只使用一个完整的固定大小的背景图像、边框和所有内容,并在顶部覆盖一个无边框的表格。毕竟桌子总是一样大的。
谁能想到更好的方法?
我需要将桌子设计成圆角。
我只是在看看如何最好地去做:
通常,当我将 div 样式设置为圆角时,我会使用 2 个 div,顶部和底部带有空注释,并对其应用尺寸和背景图像 CSS。
然而,表格有内部边框,所以我必须仔细对齐角落 bg 图像中的垂直线,以匹配真正的单元格边框。
到目前为止,这清楚吗?
所以我想知道其他人会如何处理这个问题。我认为我能做的最好的事情就是只使用一个完整的固定大小的背景图像、边框和所有内容,并在顶部覆盖一个无边框的表格。毕竟桌子总是一样大的。
谁能想到更好的方法?
25 种方法...... http://www.cssjuice.com/25-rounded-corners-techniques-with-css/
实际上,有太多的方法可以做到这一点。
你最好制作一个只有角落而不是边框的背景图像。将一个类应用于左上角、右上角、左下角和右下角单元格,以定义应使用角背景图像。
并使用 css 设置边框样式。不要将它们放在背景图像中。
在您的方法中,您最终将始终使背景图像中的垂直线与实际表格单元格的边框不匹配。
更好的方法是 9 网格,其中您有背景角,并且顶部、底部、左侧和右侧背景重复
您的表格进入单元格 5
正如一些在评论中发布的那样,您无法使用 9-grid 实现效果。你必须做一个 12 网格系统(由我现在组成 :)
.
警告:它不漂亮,但有效
<html>
<head>
<style>
.cell1 {background: #f8f8f8 url(images/cell1.gif) no-repeat left top; height: 10px; font-size: 1px;}
.cell2 {background: #f8f8f8 url(images/cell2.gif) repeat-x top; height: 10px; font-size: 1px; border-right: solid 1px #c3c2c2; font-weight:bold; }
.cell3 {background: #f8f8f8 url(images/cell3.gif) no-repeat right top; height: 10px; font-size: 1px;}
.cell4 {background: white url(images/cell4.gif) repeat-y left; border-bottom: solid 1px #c3c2c2; width: 13px; }
.cell5 {background-color: #f8f8f8; padding: 5px; border-right: solid 1px #c3c2c2; font-weight:bold; border-bottom: solid 1px #c3c2c2; }
.cell6 {background: white url(images/cell6.gif) repeat-y right; border-bottom: solid 1px #c3c2c2; width: 18px; }
.cell7 {background: white url(images/cell7.gif) repeat-y left; width: 13px;}
.cell8 {background-color: white; padding: 5px; border-right: solid 1px #c3c2c2; font-weight:normal; }
.cell9 {background: white url(images/cell9.gif) repeat-y right; width: 18px;}
.cell10 {background: white url(images/cell10.gif) no-repeat left bottom; height: 17px;font-size: 1px; }
.cell11 {background: white url(images/cell11.gif) repeat-x bottom; border-right: solid 1px #c3c2c2; height: 17px; font-size: 1px; }
.cell12 {background: white url(images/cell12.gif) no-repeat right bottom; height: 17px;font-size: 1px; }
.lastcolumn, th.lastcolumn, td.lastcolumn {border-right: solid 0px #c3c2c2; }
</style>
</head>
<body>
<table id="pricing" border="0" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="cell1"></th>
<th class="cell2"> </th>
<th class="cell2"> </th>
<th class="cell2"> </th>
<th class="cell2"> </th>
<th class="cell2"> </th>
<th class="cell2 lastcolumn"> </th>
<th class="cell3"></th>
</tr>
<tr>
<th class="cell4"> </th>
<th class="cell5">Incoming calls</th>
<th class="cell5">National calls</th>
<th class="cell5">Calls to US & Canada</th>
<th class="cell5">Calls to other Phones</th>
<th class="cell5">Calls to other Countries</th>
<th class="cell5 lastcolumn">SMS text messages</th>
<th class="cell6"> </th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell7"></td>
<td class="cell8">Select</td>
<td class="cell8">country</td>
<td class="cell8">from</td>
<td class="cell8">dropdown</td>
<td class="cell8">list</td>
<td class="cell8 lastcolumn">above</td>
<td class="cell9"></td>
</tr>
<tr>
<td class="cell10"></td>
<td class="cell11"> </td>
<td class="cell11"> </td>
<td class="cell11"> </td>
<td class="cell11"> </td>
<td class="cell11"> </td>
<td class="cell11 lastcolumn"> </td>
<td class="cell12"></td>
</tr>
</tbody>
</table>
</body>
</html>
注意:SO 从代码中删除了一些不间断的空格。查看现场演示以获取更多信息
享受!
做这样的事情...
XHTML:(抱歉必须删除第一个'<',因为它不会让我正常发布它,FIX THIS JEFF!)
table id="pricing" border="0" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>Incoming calls</th>
<th>National calls</th>
<th>Calls to US & Canada</th>
<th>Calls to other Phones</th>
<th>Calls to other Countries</th>
<th>SMS text messages</th>
</tr>
</thead>
<tbody>
<tr>
<td>Select</td>
<td>country</td>
<td>from</td>
<td>dropdown</td>
<td>list</td>
<td>above</td>
</tr>
</tbody>
</table>
CSS:#pricing { 字体重量:粗体;文本对齐:中心 }
#pricing thead
{
background-image:url("images/pricing_top.gif");
background-position:top;
background-repeat:no-repeat;
padding:10px 0 0 /* replace 10px with the height of pricing_top.gif */
}
#pricing th
{
background-image:url("images/pricing_header_bg.gif");
background-repeat:repeat-y;
border-bottom:1px solid #c3c2c2;
width:100px /* replace 100px with the width of pricing_header_bg.gif */
}
#pricing tbody
{
background-image:url("images/pricing_bottom.gif");
background-position:bottom;
background-repeat:no-repeat;
padding:0 0 10px /* replace 10px with the height of pricing_bottom.gif */
}
#pricing td
{
background-image:url("images/pricing_cell_bg.gif");
background-repeat:repeat-y;
width:100px /* replace 100px with the width of pricing_cell_bg.gif */
}
唯一的缺点是您必须创建 4 个图像,但这不会花费太长时间。如果您想在右侧添加阴影并相应地更改它的背景图像和宽度属性,您还需要在每行的最后一个单元格中添加一个类。
发挥您最初的想法,您可以为每个角落单元格添加一个类,有效地关闭它们各自的违规边界。然后,您可以在 <thead> 和 <tfoot> 元素中使用全角背景图像来解决圆角问题。
其余单元格的边框可以打开,线条将正确排列。
剩下的唯一问题是解释那个爆炸的阴影。那是一个不同的练习。