Reputation: 377
I'm doing an ASP.NET MVC website and I have a little question about Razor.
I'm using an
@Html.DisplayFor(model => model.description)
To show the description of a product. But if the description is really long like :
This description is really long and I don't want to scroll to see the end of it
It's really awful to scroll to the right to see the end of it...
How can I do to have a display like this :
This description is really
long and I don't
want to scroll to see
the end of it
Can I do it with displayfor ?
Thanks in advance for your help
Upvotes: 0
Views: 1645
Reputation: 8183
You could do something like this:
CSS
.wordwrap{
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -webkit-pre-wrap; /*Chrome & Safari */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* css-3 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}
View
<div class="wordwrap">
@Html.DisplayNameFor(model => model.description})
</div>
Upvotes: 2