我需要将桌子设计成圆角。

我只是想看看如何最好地去做:

通常,当我将 div 设置为圆角时,我会使用顶部和底部带有空注释的 2 个 div,并对它们应用调整大小和背景图像 CSS。

然而,该表格有内部边框,因此我必须仔细对齐角落背景图像中的垂直线,以与真实的单元格边框相匹配。

这是清楚的吗?

所以我想知道其他人会如何处理这个问题。我认为我能做的最好的事情就是只使用一个完整的固定大小的背景图像、边框和所有内容,并在顶部覆盖一个无边框表格。毕竟桌子的大小总是相同的。

有人能想出更好的办法吗?

有帮助吗?

解决方案

你最好制作一个只有角的背景图像,而不是边框​​。将类应用于左上角、右上角、左下角和右下角单元格,以定义应使用角背景图像。

并使用 css 设置边框样式。不要将它们放在背景图像中。

在您的方法中,您总是会发现背景图像中的垂直线与实际表格单元格的边框不匹配。

其他提示

25种方法.... http:/ /www.cssjuice.com/25-rounded-corners-techniques-with-css/

实际上,有太多方法可以做到。

您是否尝试过 http://www.roundedcornr.com/

做这样的事......

XHTML :(抱歉必须删除第一个'<!> lt;',因为它不会让我正常发布,修复这个杰夫!)

table id="pricing" border="0" cellpadding="0" cellspacing="0">
  <thead>
    <tr>
      <th>Incoming calls</th>
      <th>National calls</th>
      <th>Calls to US &amp; 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 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个图像,但这不应该花费太长时间。如果要在右侧添加该阴影,只需相应地更改它的background-image和width属性,您还需要在每行的最后一个单元格中添加一个类。

根据您原来的想法,您可以为每个角落单元添加一个类,从而有效地关闭各自的违规边框。然后,您可以在<!> lt; thead <!> gt;中使用全宽背景图像。和<!> lt; tfoot <!> gt;要考虑圆角的元素。

其他单元格的边框可以打开,线条也会正确排列。

唯一剩下的问题是应对爆破的阴影。这是一个不同的练习。

更好的方法是9格,你有背景角,顶部,底部,左右背景重复

你的表进入单元格5

修改

正如一些人在评论中发表的那样,用9格无法达到效果。 你必须做一个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">&nbsp;</th>
      <th class="cell2">&nbsp;</th>
      <th class="cell2">&nbsp;</th>
      <th class="cell2">&nbsp;</th>
      <th class="cell2">&nbsp;</th>
      <th class="cell2 lastcolumn">&nbsp;</th>
      <th class="cell3"></th>
    </tr>
    <tr>
      <th class="cell4">&nbsp;</th>
      <th class="cell5">Incoming calls</th>
      <th class="cell5">National calls</th>
      <th class="cell5">Calls to US &amp; 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">&nbsp;</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">&nbsp;</td>
      <td class="cell11">&nbsp;</td>
      <td class="cell11">&nbsp;</td>
      <td class="cell11">&nbsp;</td>
      <td class="cell11">&nbsp;</td>
      <td class="cell11 lastcolumn">&nbsp;</td>
      <td class="cell12"></td>
    </tr>
  </tbody>
</table>


</body>
</html>

注意:代码中有一些不间断的空格。查看生活演示了解更多信息

享受!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top