为什么有不必要的填充?

时间:2018-01-24 22:02:27

标签: css

<div style="background-color: #EEEEEE; display: inline-table;">
  <div style="display: inline-table;  width: 100%">
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame00.gif"></div>
    <div style="display: table-cell; height: 5px; background-image: url('/design/_messages/frameUP.gif');"></div>
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame01.gif"></div>
  </div>
  <div style="display: inline-table; width: 100%">
    <div style="display: table-cell; width: 5px; background-image: url('/design/_messages/frameLEFT.gif');"></div>
    <div style="display: table-cell; margin: 0; padding: 0; border: none">sdfkl sdklf jklfff ffff fff fff fffffsjdf klsfffff fff fjdf</div>
    <div style="display: table-cell; text-align: right; width: 5px; background-image: url('/design/_messages/frameRIGHT.gif');"></div>
  </div>
  <div style="display: inline-table;  width: 100%">
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame10.gif"></div>
    <div style="display: table-cell; height: 5px; background-image: url('/design/_messages/frameDOWN.gif');"></div>
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame11.gif"></div>
  </div>

https://jsfiddle.net/Lsroqeyg/

右边有一个不必要的间距。右边太远了。看图像: enter image description here

1 个答案:

答案 0 :(得分:1)

将父元素的显示更改为内联网格,如下所示

&#13;
&#13;
<div style="background-color: #EEEEEE; display: inline-grid;"> <!--inline-grid here-->
  <div style="display: inline-table;  width: 100%">
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame00.gif"></div>
    <div style="display: table-cell; height: 5px; background-image: url('/design/_messages/frameUP.gif');"></div>
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame01.gif"></div>
  </div>
  <div style="display: inline-table; width: 100%">
    <div style="display: table-cell; width: 5px; background-image: url('/design/_messages/frameLEFT.gif');"></div>
    <div style="display: table-cell; margin: 0; padding: 0; border: none">sdfkl sdklf jklfff ffff fff fff fffffsjdf klsfffff fff fjdf</div>
    <div style="display: table-cell; text-align: right; width: 5px; background-image: url('/design/_messages/frameRIGHT.gif');"></div>
  </div>
  <div style="display: inline-table;  width: 100%">
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame10.gif"></div>
    <div style="display: table-cell; height: 5px; background-image: url('/design/_messages/frameDOWN.gif');"></div>
    <div style="display: table-cell; width: 5px; height: 5px;"><img src="/design/_messages/frame11.gif"></div>
  </div>
&#13;
&#13;
&#13;