我正在尝试从图片标签中设置标题的样式。
我搜索了其他问题,但它不能在我的元素中工作。
但我无法进行任何更改。
有人可以帮我解决这个问题吗?
我的代码:
table.tablesorter tbody tr td a:hover img[title]:after
{
content: attr(title);
padding: 4px 8px;
color: #FFF;
background-color:black;
}
<table class="tablesorter" style="width:98% !important">
<thead>
<tr>
<th>
.....
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
..........
</td>
<td>
<a href="@Url.Action("Edit","Account", new { id=item.UserId })">
<img src="~/Content/images/icon_edit.png" title="Edit"/>
</a>
</td>
</tr>
</tbody>
<tfooter>
</tfooter>
</table>
最佳答案
应该是content: attr(title);
, 不是 content: attr(data-title);
- 你没有数据属性。
另外,似乎::before
和 ::after
没有为 img
定义伪元素- 你可能需要使用其他东西:
CSS Content attribute for IMG tag
工作示例(当图像丢失时):http://jsfiddle.net/DMAFm/
另一个例子,使用 title
在 <a>
上标签:http://jsfiddle.net/DMAFm/1/
关于asp.net - CSS - 为图像标签设置标题样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18405536/