如何减少表格单元格之间的空间?

时间:2016-12-01 22:44:13

标签: html css twitter-bootstrap

我试图减少照片下方名称行中的单元格之间的空间。我已经尝试过没有运气的一切。谁能告诉我如何让名字在桌子内坐得更近?我做了一个小提琴here。我使用bootstrap 3.非常感谢

Html

<div class="container">

  <div class="col-xs-12 col-md-6 col-sm-8 col-lg-6 center-block animated fadeInUp">

    <div class="results">
      <ul id="results">
        <!-- results appear here -->
        <h3>
 Image title
</h3>
        <div class="dark">
          <a href="page.php?page_id=241"><img src="http://www.fiji.travel/sites/default/files//styles/views-large-thumbnail/public/arial-of-island.jpg?itok=KZHGX6pJ" width="600" class="img-responsive" alt=""></a>
        </div>





        <small>posted by:

                                         <a href="profile.php?user_id=user_id" span="" class="">
                                                Anderson</a></small>

<!-Make These names sit closer together--->
        <table id="myTable2" border="0" cellpadding="0" cellspacing="0" class="table" style="width:auto;">
          <tbody>

            <tr style="\&quot;display:none;\&quot;">
              <td valign="top"><strong><a href="profile.php?user_id=6" class="tags" style="color:">
                                                Anderson,</a>&nbsp;</strong></td>
              <td valign="top"><strong><a href="profile.php?user_id=9" class="tags" style="color:#3cb0fd">
                                                James Bond,</a>&nbsp;</strong></td>
              <td valign="top"><strong><a href="profile.php?user_id=2" class="tags" style="color:">
                                                Julian,</a>&nbsp;</strong></td>
            </tr>
          </tbody>
        </table>
        <hr>

2 个答案:

答案 0 :(得分:2)

将此添加到您的css:

#myTable2 td {
  padding: 0 0;
}

它将删除你想要删除的填充,并且单元格将紧挨着彼此。

答案 1 :(得分:0)

您需要CSS重置脚本。无论何时构建新站点,请将其作为最顶层的CSS脚本。它会在所有元素上将填充和边距设置为零。在表格单元格上,默认填充通常为2px。

还有其他人,但这个并不是一个糟糕的开始。来自http://meyerweb.com/eric/tools/css/reset/

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}