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
4.5k views
in Technique[技术] by (71.8m points)

html - Enter a line between the column title and the search box text in the header table

I have a table. At the bottom of the search columns, I put a text box. See in this link: https://jsfiddle.net/rm1pt3Lz/

my code is:

      <table cellspacing="0" cellpadding="0" id=cnttable>
        <thead>
          <tr>
          <th style="width:36%;text-align:left;font-size:17px;">     
              <div>
                 Select
              </div>
              
              <div>
                 <input type="checkbox"/>
              </div> 
          </th>
          
          <th style="width:20%;text-align:left;font-size:17px;">
              <div>
                 Designation
              </div>
               <div>
                  <input id="x2" type="text" style="padding:5px"/>
              </div>
         </th>
           
         <th style="width:15%;text-align:left;font-size:17px;">
            <div>
               <a href="google.com">Mobile</a>
            </div>
            <div>
               <input id="x3" type="text" style="padding:5px"/>
            </div>
         </th>
              
        <th style="width:24%;text-align:left;font-size:17px;">Operation
            <div>
        
              </div>
        </th>        
      </tr>
      </thead>
      <tbody>
          <tr>
            <td></td>
            <td>text1</td>
            <td>0052522222</td>
            <td></td>
          </tr>
          <tr>
            <td></td>
            <td>text2</td>
            <td>00525227652</td>
            <td></td>
          </tr>
      </tbody>
    
    </table>

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

1 Reply

0 votes
by (71.8m points)

First split the inputs on to their own row, they will be much easier to mangage. Then you can use some basic CSS to give them a background color to create your line. A bit of padding and a different font can also go a long way. I'd also suggest eleminating most of your inline styles and using CSS classes instead. Its much easier to maintain and work with.

html, body {
  margin: 0px;
  font-family: Arial;
}

table {
  width: 100%;
}

th {
  box-sizing: border-box;
  padding: 8px;

  font-size: 17px;
  text-align: left;
}

/*Inputs*/
thead td {
  background-color: #e8e9e8;
  padding: 8px;
}
<table cellspacing="0" cellpadding="0" id="cnttable">
  <thead>
    <tr>
      <th style="width:36%;">
        Select
      </th>

      <th style="width:20%;">
        Designation
      </th>

      <th style="width:15%;">
        <a href="google.com">Mobile</a>
      </th>

      <th style="width:24%;">
        Operation
      </th>
      
     </tr>
     <tr>

      <td>
        <input type="checkbox" />
      </td>
      <td>
        <input id="x2" type="text" style="padding:5px" />
      </td>
      <td>
        <input id="x3" type="text" style="padding:5px" />
      </td>
      <td>

      </td>

    </tr>
  </thead>
  <tbody>
    <tr>
      <td></td>
      <td>text1</td>
      <td>0052522222</td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td>text2</td>
      <td>00525227652</td>
      <td></td>
    </tr>
  </tbody>

</table>

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

1.4m articles

1.4m replys

5 comments

57.0k users

...