Reputation: 4443
I want to show in my view list of all comments from database. But sometimes, comments ale very long. I tried to "break" them with word-wrap:break-word
, but with no result - comments like this
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
extend my view..
and I want to show:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
How to do it? CSS Width
property also don't work.
Here is my code:
<table style="width: 100%;">
@foreach (var comment in Model.commentList)
{
<tr style="border-bottom:1pt solid black;">
<td style="width: 30%;">
<br />
@comment.UserName<br /><br />
@comment.AddDate
</td>
<td style="word-wrap:break-word; width: 70%;">
<br />
@comment.Content
</td>
</tr>
}
</table>
Upvotes: 0
Views: 2005
Reputation: 76
Actually word-wrap: break-word
doesn't seem to work normally in tables. There is a fix for it though. Try the following code (note the additional table-layout: fixed
in the table
tag).
<table style="table-layout: fixed; width: 100%;">
@foreach (var comment in Model.commentList)
{
<tr style="border-bottom:1pt solid black;">
<td style="width: 30%;">
<br />
@comment.UserName<br /><br />
@comment.AddDate
</td>
<td style="word-wrap:break-word; width: 70%;">
<br />
@comment.Content
</td>
</tr>
}
</table>
Upvotes: 2