我希望表格的每个单元格边框都有填充和点缀

时间:2012-11-09 12:40:35

标签: html

我希望每个单元格的边框如下图所示:

<table border="1" width="90%">
<tr>
    <th>NAME OF OFFEROR</th>
    <th>EMPLOYER</th>
    <th>FAMILY/BECHLOR</th>
    <th>NATURE OF LEASE</th>
    <th>RENT</th>
    <th>DEPOSIT</th>
    <th>TERM OF LEASE</th>
</tr>
<?PHP
    $query=mysql_query("select name,company,categary,lease,tol,rent,deposit from client_enquiry where pro_id='".$property."'") or die(mysql_error());
    while($row=mysql_fetch_row($query))
    {
        echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[5]."</td><td>".$row[6]."</td><td>".$row[4]."</td></tr>";
    }
?>
</table>

enter image description here

3 个答案:

答案 0 :(得分:0)

查看CSS属性:

border
border-spacing

并将它们应用到你的桌子上。

答案 1 :(得分:0)

您应该发布HTML和CSS以显示您尝试过的内容。

顺便说一句,您可以在TD中使用div来获取border-bottom:

http://jsfiddle.net/jzx2N/2/

编辑:保持TD高度和宽度对齐的新代码...

enter image description here

CSS

table{
  border-collapse: collapse;
  margin: 20px;  
}

td{
   padding-top: 15px;
   padding-bottom: 15px;
   border-right: 2px dotted silver;
   border-left: 2px dotted silver;
   vertical-align: bottom;
   width: 33%;
}

.tdLeft{
   border-left: none;
}

.tdRight{
   border-right: none;
}

.innerDiv{
    border-bottom: 2px dotted silver;
    padding-left: 20px;
    padding-right: 20px;
    height: 100%;
    margin-left: 20px;
    margin-right: 20px;
    padding-bottom: 20px;
}

HTML

<table>
    <tr>
        <td class="tdLeft">
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>
        <td>
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>
        <td class="tdRight">
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>        
    </tr>    
    <tr>
        <td class="tdLeft">
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>
        <td>
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>
        <td class="tdRight">
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>        
    </tr>
    <tr>
        <td class="tdLeft">
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>
        <td>
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>
        <td class="tdRight">
            <div class="innerDiv">
             Stuff on column
            </div>
        </td>        
    </tr>
</table>

答案 2 :(得分:0)

我在这里为你做了一个例子:http://jsfiddle.net/paulalexandru21/yyjtB/

我建议你不要使用桌子,因为它们有点老元素,不是很优化。 Div是更好的。代码如下所示:

HTML:

    <div class="col border">
    <div class="head">
        <p>Gold</p>
        <small>FREE</small>         
    </div>
    <ul>
        <li><b>5</b> products</li>            
        <li><b>1</b> image per product</li>
        <li><b>Basic</b> stats</li>
        <li><b>Basic</b> customization</li>        
    </ul>
</div>
<div class="col border">
    <div class="head">
        <p>Platinum</p>
        <small>FREE</small>        
    </div>
    <ul>
        <li><b style="color: #76CAC6">25</b> products</li>
        <li><b style="color: #76CAC6">3</b> image per product</li>
        <li><b style="color: #76CAC6">Better</b> stats</li>
        <li><b style="color: #76CAC6">Full</b> customization</li>        
    </ul>
</div>
<div class="col border">
    <div class="head">
        <p>Diamond</p>
        <small>FREE</small>        
    </div>
    <ul>
        <li><b style="color: #87BE84">100</b> products</li>
        <li><b style="color: #87BE84">5</b> image per product</li>
        <li><b style="color: #87BE84">Best</b> stats</li>
        <li><b style="color: #87BE84">Full</b> customization</li>        
    </ul>
</div>

CSS:

    html, body {font-family: arial;}

.col {
    height: 500px;
    width: 200px;
    float: left;
}

.arange {
    padding-top: 20px;
    background: pink;
}

.border {
    border-right: 1px dotted gray;
}

.head{
    padding-top: 20px;
    background: #000;
    color: #FFF;
    width: 200px;
    height: 90px;
    lign-height: 100px;
}

p {
    font-size: 18pt;
    font-family: arial;
    color: white;
    margin-left: 20px;
}

small {
    font-size: 10pt;
    font-family: arial;
    color: gray;
    font-weight: bold;
    margin-left: 20px;
}

ul {
    margin-left: 20px;
    margin-right: 20px;
    color: gray;
}

ul li {
    padding: 10px 0px;
    border-bottom: 1px dotted gray;
    font-size: 15px;
}

blue {color: #76CAC6;}