user2232273 user2232273 - 9 days ago 3
ASP.NET (C#) Question

CSS - Style the title from the image tag

I'm trying to style the title from the image tag.

I have search other question but can´t it put working in my project.

But I can´t make any changes.

Someone can give me hand with this pls?

my code:



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>




Answer

It should be content: attr(title);, not content: attr(data-title); - you don't have a data attribute.

Also, it seems ::before and ::after pseudo-elements are not defined for img - you may have to use something else:
CSS Content attribute for IMG tag

Working Example (when the image is missing): http://jsfiddle.net/DMAFm/
Another example, with the title on the <a> tag: http://jsfiddle.net/DMAFm/1/