Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

html - How to keep the border double between cells?

Here is my code:

#tb2 td { display:block }
<table border="1" id="tb1">
  <td>1) text</td>
  <td>2) text</td>
  <td>3) text</td>
</table>

<hr/>

<table border="1" id="tb2">
  <td>1) text</td>
  <td>2) text</td>
  <td>3) text</td>
</table>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I do not understand the reason for the question.

Don't use side effects of random elements because you want to use deprecated inline BORDER attribute

There is not particular need to know why something does not work when it is not valid markup. To fix it, use valid markup

See my second example. It looks the way it should because it is valid markup

The third is also valid but is using divs

Without border or extra HTML, you can try this:

td {
  width: 50px;
  padding 2px;
  margin 2px;
}

#tb2 td {
  display: block;
}

div.border {
  width: 50px;
  padding: 1px;
  border: 2px solid black;
  margin: 2px;
}

div.container {
  width: 60px
}
<table border="1" id="tb1">
  <td>1) text</td>
  <td>2) text</td>
  <td>3) text</td>
</table>

<hr/>

<table border="1" id="tb2">
  <tbody>
    <tr>
      <td>1) text</td>
    </tr>
    <tr>
      <td>2) text</td>
    </tr>
    <tr>
      <td>3) text</td>
    </tr>
  </tbody>
</table>

<hr/>

<div class="border container">
  <div class="border">1) text</div>
  <div class="border">2) text</div>
  <div class="border">3) text</div>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...