如何显示隐藏的对象

时间:2018-08-06 21:01:44

标签: css hover

对于我来说,我想在启动时隐藏十字,当我将鼠标悬停在鼠标上时,它应该是可见的,但它不起作用:

table, th, td {
   border: 1px solid black;
   padding: 10px;
}

table {
    border-collapse: collapse;
}

i {
  cursor: pointer;
  visibility: hidden;
}

i:hover {
  visibility: visible;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<table>
<tr>
  <td>Example text</td>
  <td><i class="fa fa-times-circle"></i></td>
</tr>
</table>

1 个答案:

答案 0 :(得分:1)

改为更改opacity属性:

table,
th,
td {
  border: 1px solid black;
  padding: 10px;
}

table {
  border-collapse: collapse;
}

i {
  cursor: pointer;
  opacity: 0;
}

i:hover {
  opacity: 1;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<table>
  <tr>
    <td>Example text</td>
    <td><i class="fa fa-times-circle"></i></td>
  </tr>
</table>