如何删除段落和表格之间的空格

时间:2017-07-11 11:26:03

标签: jquery html css

我正在动态显示表格和段落,但我们如何删除段落和表格之间的空格?我通过边距和填充0来尝试它,但仍有空间,

下面是我的代码:

var out = "<br/><p>&nbsp&nbsp&nbsp&nbspConfirmed Batches</p>";
//var out="";
//out+="<center><table><tr><td>Confirmed Batches</td></tr></table>;
out += "<table  border='2' cellpadding='1' cellspacing='0' rules=none >";
//out+="<tr><td>Confirmed Batches</td></tr>";
out += "<tr><th width='100' height='40' >&nbsp&nbspBatch Code</th><th width='100' height='45'><center>Start Date</center></th><th width='50' align='center' height='45'><center>Day</center></th><th width='120' align='center' height='45'><center>Batch time</center></th><th width='150' align='center' height='45'><center>Trainer</center></th><th width='100' align='center' height='45'><center>Frequency</center></th><th width='50' align='center' height='45' ><center>Fees</center></th><th width='110' align='center' height='45'><center>Duration</center></th></th></tr>";
$("body").append(out);
table {
  //border:5;
  margin-left: 20px;
  margin-top: 0px;
  margin-bottom: 0px;
  width: 800px;
  border-collapse: collapse;
  border-spacing: 0;
  //border-color:green;
  //background-color:#EBF5FB;
}

p {
  margin-bottom: 0px;
  margin-top: 0px;
  font-size: 15px;
  color: #C8E786;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

1 个答案:

答案 0 :(得分:0)

也许你的意思是

&#13;
&#13;
th {
  height: 45px;
  text-align: center;
}
&#13;
<fieldset>
  <legend>Confirmed Batches</legend>
  <table cellpadding='1' cellspacing='0' rules=none>

    <tr>
      <th width='100'>Batch Code</th>
      <th width='100'>Start Date</th>
      <th width='50'>Day</th>
      <th width='120'>Batch time</th>
      <th width='150'>Trainer</th>
      <th width='100'>Frequency</th>
      <th width='50'>Fees</th>
      <th width='110'>Duration</th>
    </tr>
  </table>
</fieldset>
&#13;
&#13;
&#13;