gpt4 book ai didi

css - 在td上显示左上角的图标

转载 作者:太空宇宙 更新时间:2023-11-04 07:40:31 26 4
gpt4 key购买 nike

目标:
当您将光标放在 td 上时,在所选 td 的左上角显示图标。

问题:
我试图找到不同的解决方案,但进展并不顺利。

谢谢!

table.glyphicon-hover .glyphicon {
visibility: hidden;
}

table.glyphicon-hover td:hover .glyphicon {
visibility: visible;
position:relative;
background-color: green;

}

.test {
text-align:right;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />


<body>

<div class="container">


<table class="test table table-striped glyphicon-hover">
<tr>
<th>kkjkjkjkjsfdsdfg</th>
</tr>
<tr>
<td>
<span class="glyphicon glyphicon-thumbs-up"><img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-trash-a-20.png"></span>
<span>sfsdf!</span> <br>sdfsdf <br>sdfsdf <br> sdfsdf
</td>
</tr>

<tr>
<td>
sdsdfsdf sf <span class="glyphicon glyphicon-thumbs-up"></span>
</td>
</tr>
</table>


</div>

最佳答案

您需要将td 设置为相对定位,将图标设置为绝对定位。然后您可以使用 lefttop 定位它。

table.glyphicon-hover .glyphicon {
visibility: hidden;
position:absolute;
}

table.glyphicon-hover td:hover .glyphicon {
visibility: visible;
background-color: green;
left: 0;
}

.table td {
position: relative
}

.test {
text-align:right;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />


<body>

<div class="container">


<table class="test table table-striped glyphicon-hover">
<tr>
<th>kkjkjkjkjsfdsdfg</th>
</tr>
<tr>
<td>
<span class="glyphicon glyphicon-thumbs-up"><img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-trash-a-20.png"></span>
<span>sfsdf!</span> <br>sdfsdf <br>sdfsdf <br> sdfsdf
</td>
</tr>

<tr>
<td>
sdsdfsdf sf <span class="glyphicon glyphicon-thumbs-up"></span>
</td>
</tr>
</table>


</div>

关于css - 在td上显示左上角的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48565185/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com