【发布时间】:2015-12-28 11:15:42
【问题描述】:
我正在使用描述的解决方案
How can I make a link from a <td> table cell
在我的表格超链接中创建 td 条目。这是一个不错且简单的解决方案。但是当我使用 display:block; 时会产生副作用。超链接文本向上移动一点并且不居中。下图显示了问题。如果您查看选定的 td “primary”,您会发现它太高了。
否则它是完美的,因为突出显示的 td 与我想要的蓝色 th 对齐。
我该如何纠正这个问题?
我正在使用的简化代码
----html----
<td>
<div style="height:100%;width:100%;">
<a href="my_url">
primary
</a>
</div>
</td>
----css----
table {
background-color: White;
border: 10px solid Blue;
border-radius: 13px;
border-collapse: separate;
width: auto;
margin-top: 5px;
}
table th, td {
color: Black;
vertical-align: middle;
font-size: 20px;
font-weight: bold;
border: 0;
padding: 0px;
}
table th {
color: White;
background: Blue;
}
table a {
color: Black;
text-decoration: none;
display: block;
width: 100%;
height: 100%;
padding: 0px;
}
table a:hover {
color: White;
background: Blue;
}
【问题讨论】:
-
table td{text-align:center;} -
没有这样的运气。我试过了,但它似乎在 display:block; 时被忽略了。用来。为了确保我将它设置在 td、a 和 div 上。
标签: html css hyperlink html-table