Border-cellspacing无法正常工作html

时间:2016-05-14 08:34:48

标签: html html-table border-spacing

我有这个HTML代码:

<table style='border-collapse: separate; border-spacing: 10px;'>
     <tr class='signatureContainer'>
          <td class='signatureBox' style='float: left;' >
                <span>%%%employee%%%</span>
                <hr style='margin-top: 70px;' />
                <span>%%%Role%%%</span>
          </td>
          <td class='commentsBox' style='float: left'>
                <span> &nbsp; </span>
                <hr style='margin-top: 70px;' />
                <span>Comments</span>
          </td>
          <td class='signatureBox' style='float: left'>
                <span> &nbsp; </span>
                <hr style='margin-top: 70px;' />
                <span> Master &nbsp; </span>
          </td>
    </tr>
</table>

以下样式适用于它:

.signatureContainer {
display: table;
width: 100%;
margin: 30px 0 50px 0;
}
.signatureBox{
border-radius: 5px;
border-width: 1px;
border-style: solid;
border-color: rgb(128, 128, 128);
min-width: 150px;
min-height: 65px;
padding: 3px;
display: block;
margin-left: 20px;'
}
.commentsBox{
border-radius: 5px;
border-width: 1px;
border-style: solid;
border-color: rgb(128, 128, 128);
min-width: 600px;
min-height: 65px;
padding: 3px;
display: block;
margin-left: 20px;
margin-right: 20px'
}

当我运行页面时,单元格之间没有空格。查看代码您认为问题是什么,它看起来并不分开。

2 个答案:

答案 0 :(得分:0)

<table style='border-collapse: separate; border-spacing: 10px !important;'>
     <tr class='signatureContainer'>
          <td class='signatureBox' style='float: left;' >
                <span>%%%employee%%%</span>
                <hr style='margin-top: 70px;' />
                <span>%%%Role%%%</span>
          </td>
          <td class='commentsBox' style='float: left'>
                <span> &nbsp; </span>
                <hr style='margin-top: 70px;' />
                <span>Comments</span>
          </td>
          <td class='signatureBox' style='float: left'>
                <span> &nbsp; </span>
                <hr style='margin-top: 70px;' />
                <span> Master &nbsp; </span>
          </td>
    </tr>
</table>

在应用空格时设置!important

答案 1 :(得分:0)

你的错误是你的css改变它。

.signatureContainer {
display: table;
width: 100%;
margin: 30px 0 50px 0;
}
.signatureBox{
border-radius: 5px;
border-width: 1px;
border-style: solid;
border-color: rgb(128, 128, 128);
min-width: 150px;
min-height: 65px;
padding: 3px;
display: block;
margin-left: 20px;
}
.commentsBox{
border-radius: 5px;
border-width: 1px;
border-style: solid;
border-color: rgb(128, 128, 128);
min-width: 600px;
min-height: 65px;
padding: 3px;
display: block;
margin-left: 20px;
margin-right: 20px
}
<table style='border-collapse: separate; border-spacing: 10px;'>
     <tr class='signatureContainer'>
          <td class='signatureBox' style='float: left;' >
                <span>%%%employee%%%</span>
                <hr style='margin-top: 70px;' />
                <span>%%%Role%%%</span>
          </td>
          <td class='commentsBox' style='float: left'>
                <span> &nbsp; </span>
                <hr style='margin-top: 70px;' />
                <span>Comments</span>
          </td>
          <td class='signatureBox' style='float: left'>
                <span> &nbsp; </span>
                <hr style='margin-top: 70px;' />
                <span> Master &nbsp; </span>
          </td>
    </tr>
</table>