【问题标题】:How to use multiple links in one cell in html如何在html中的一个单元格中使用多个链接
【发布时间】:2016-01-07 09:57:26
【问题描述】:

我的问题是如何在一个单元格中使用多个链接?

我的 html 视图是这个,我想有关于主页、产品的链接并联系我们。

我的作业是设计一个带表格的网站:

我的代码是:

<!doctype html>
<html>
<head>
<style>
table {
    border: 1px solid black;
    border-collapse: collapse;
    border-spacing: 5px;
}
th, td {
    padding: 10px;
}
</style>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<table style="width:100%" border="1px" cellpadding="5" cellspacing="5" bordercolor="green" bgcolor="yellow" height="500px">
<caption>web design homework</caption>
<tr>
<th colspan="3">My Website</th>
</tr>
<tr  bgcolor="#77E022"
height="20px" align="left" >
<td  colspan="3" >  home  &nbsp;&nbsp;&nbsp;   products   &nbsp;&nbsp;&nbsp;   contact us  
 </td>
</tr>
<tr>
<td width="25%"> last post </td>
<td rowspan="2" width="50%"> hello my name is mohammad ghorbani and i am studying computer enginerring in arak </td>
<td> our friends </td>
</tr>
<tr>
<td> our statics </td>
<td> 24 </td>
</tr>
</table>

</body>
</html>

【问题讨论】:

  • 真的有必要用表格进行布局编码吗?其 10 多年的技术。
  • 这是家庭作业的人。我没有选择。
  • 显然你对前端开发一无所知。在 w3schools.com 上查看 HTML、CSS 和 JavaScript
  • @ebilgin 为什么选择 w3schools? MDN 文档要好得多。
  • @0x860111 因为与 MDN 相比,它非常适合初学者。如果您知道什么是前端开发,您应该查看 MDN。

标签: html html-table cell


【解决方案1】:

只需在文本中添加链接,例如更改:

contact us

到

<a href="www.google.com">contact us</a>

【讨论】:

    【解决方案2】:

    可能是这样的:

    <a href="url1"> home </a>  &nbsp;&nbsp;&nbsp;   <a href="url2"> products </a>  &nbsp;&nbsp;&nbsp;   <a href="url3"> contact us </a>  
    

    【讨论】:

      【解决方案3】:

      table {
          border: 1px solid black;
          border-collapse: collapse;
          border-spacing: 5px;
      }
      th, td {
          padding: 10px;
      }
      <table style="width:100%" border="1px" cellpadding="5" cellspacing="5" bordercolor="green" bgcolor="yellow" height="500px">
        <caption>web design homework</caption>
        <tr>
          <th colspan="3">My Website</th>
        </tr>
        <tr  bgcolor="#77E022" height="20px" align="left" >
          <td  colspan="3" >
            <a href="/home">home</a>
            <a href="/products">products</a>
            <a href="/contact">contact us </a>
         </td>
        </tr>
        <tr>
          <td width="25%"> last post </td>
          <td rowspan="2" width="50%"> hello my name is mohammad ghorbani and i am studying computer enginerring in arak </td>
          <td> our friends </td>
        </tr>
        <tr>
          <td> our statics </td>
          <td> 24 </td>
        </tr>
      </table>

      【讨论】:

        【解决方案4】:

        只需在css下方添加锚标签

         <a href="#">home</a>
         <a href="#">products</a>
         <a href="#">contact us </a>
        

        CSS:

        a { 
        text-decoration:none;
        }
        

        【讨论】:

          【解决方案5】:
          <a href="home">home</a>
            <a href="products">products</a>
            <a href="contact">contact us</a>
          

          用上面的代码替换下面的代码

          <td  colspan="3" >  home  &nbsp;&nbsp;&nbsp;   products   &nbsp;&nbsp;&nbsp;   contact us  
          

          【讨论】:

            猜你喜欢
            • 2020-10-16
            • 2017-05-09
            • 2018-06-13
            • 2018-03-24
            • 1970-01-01
            • 2017-04-21
            • 2015-02-11
            • 2015-04-05
            • 2014-08-10
            相关资源
            最近更新 更多