如何用链接链接表的一部分?

时间:2013-06-05 07:23:55

标签: html html5 html-table

我有一张桌子,里面有许多td。第一个td是一个复选框,所以我想链接所有td的链接,不包括复选框的td,如下所示:

<ul>
  <li>
     <table>
            <tr>
               <td><input type="checkbox"/></td>
               <a href="#">
               <td>
                 name1
               </td>
               <td>
                  name2
               </td>
               </a>
            </tr>
     </table>
  </li>
</ul>

我尝试了这个,但它没有用,是不是可以这样做,或者我做错了?

4 个答案:

答案 0 :(得分:0)

试试这个

<td><a href="#">name1 &nbsp name2</a></td>

答案 1 :(得分:0)

可以尝试这个..希望它可以满足你的目的..

<ul>
   <li>
      <table>
         <tr>
            <td><input type="checkbox"/></td>
            <td colspan="2">
                <a href="#"> name1 name2 </a>
            </td>
         </tr>
      </table>
   </li>
</ul>

答案 2 :(得分:0)

嗯,一个非常脏的解决方案就是制作一个覆盖整个tr的position:absolute;锚(第一个除外)。像这样:

<td>
  <a class="link" href="#"></a>
  name1
</td>

a.link {
    background:transparent; 
    width:70%; /* I set this width because it fits aproximately with the `<tr>`excluding the first `<td>` */ 
    position:absolute;  /*The magic */
    height:1em;
}

但是......这是一个肮脏的解决方案。无论如何,我不确定它是否有帮助,here's the Fiddle;)

答案 3 :(得分:-1)

尝试,

<td>
    <a href="#">
             name1
  </td>
           <td>
              name2
   </a>
   </td>