Issue
I would like to right align an image in a cell AND still keep the text centered in the cell. I am using a float:right on the image which displays it correctly, however it pushes the text to the left the width of the image so it is no longer centered. Is there a way to keep the text centered?
<table>
<tr>
<td style="text-align:center" width:"100">text
<img src="~/images/pencil1.png" height="25" width="25" style="float: right;" />
</td>
</tr>
</table>
Solution
You can add position relative to td and position absolute to image and then, set righ=0 in the image
<table style="width:100%">
<tr>
<td style="text-align:center;position:relative">
text
<img src="~/images/pencil1.png" height="25" width="25" style="position:absolute;right:0" />
</td>
</tr>
</table>
Also, if you want your table become 100%, you must set the style in the table, not in the cell.
Take in mind that your text may be under the image. You can put the text over the image if you want avoid this or use a semitransparent image.
Answered By - Victor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.