如何缩小表格中两个图像列之间的列间距?

时间:2018-03-07 06:30:24

标签: html css

这是jsfiddle:https://jsfiddle.net/3sr65bx2/3/

我尝试了许多不同的基本方法,似乎没有任何工作。我想做的就是缩小两列之间的差距。如何轻松调整代码以缩小差距?这个noobie我非常感谢你的帮助!

HTML& CSS

.box2 {
  background: grey;
  padding: 40px 40px 40px 40px;
  text-align: center;
}

.portfolioimg {
  background: yellow;
}

td img {
  width: 80%;
  margin-left: 10%;
  padding-bottom: 2px;
  padding-top: 5px;
}
<div class="box2">
  <p>
    To be, or not to be: that is the question: whether 'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arms against a sea of troubles, and by opposing end them? To die: to sleep; no more; and, by a sleep to say we
    end the heart-ache and the thousand natural shocks that flesh is heir to, 'tis a consummation devoutly to be wish'd.
  </p>
</div>

<div class="portfolioimg">
  <table>
    <tr>
      <td><img src="https://s13.postimg.org/fjvm1u9xz/pic1.png" </td>
        <td><img src="https://s13.postimg.org/4myvqxf5z/pic2.png" </td>
    </tr>
    <tr>
      <td><img src="https://s13.postimg.org/87ur9ueh3/pic3.png" </td>
        <td><img src="https://s13.postimg.org/3lyn1kdjb/pic4.png" </td>
    </tr>
    <tr>
      <td><img src="https://s13.postimg.org/x14banptj/pic5.png" </td>
        <td><img src="https://s13.postimg.org/ctqviei2f/pic6.png" </td>
    </tr>
  </table>
</div>

2 个答案:

答案 0 :(得分:0)

据我了解,我认为您必须max-width:80%使用imgtext-align:righttd tr >

Stack Snippet

&#13;
&#13;
.portfolioimg {
  background: yellow;
}

td img {
  max-width: 80%;
}

tr td:first-child {
  text-align: right;
}
&#13;
<div class="portfolioimg">
  <table>
    <tr>
      <td><img src="https://s13.postimg.org/fjvm1u9xz/pic1.png"></td>
      <td><img src="https://s13.postimg.org/4myvqxf5z/pic2.png"></td>
    </tr>
    <tr>
      <td><img src="https://s13.postimg.org/87ur9ueh3/pic3.png"></td>
      <td><img src="https://s13.postimg.org/3lyn1kdjb/pic4.png"></td>
    </tr>
    <tr>
      <td><img src="https://s13.postimg.org/x14banptj/pic5.png"></td>
      <td><img src="https://s13.postimg.org/ctqviei2f/pic6.png"></td>
    </tr>
  </table>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

更改td的css

td{
margin-right: -40px;
display: block;
}