I\'m trying to create a word-wrap in JavaScript using CSS, and the condition is:
If DIV contains one very long word, such as \"asdasfljashglajksgkjasghk
If you can guarantee the content will run over, here is the solution I came up. It works for my site and I wanted to keep it simple.
html:
[content]
css:
.snippet {
position: relative;
height: 40px; // for 2 lines
font-size: 14px; // standard site text-size
line-height: 1.42857; // standard site line-height
overflow: hidden;
margin-bottom: 0;
}
.news-insights .snippet:after {
content: "\02026";
position: absolute;
top: 19px;
right: 0;
padding-left: 5px;
background: linear-gradient(to right, rgba(255, 255, 255, 0), white 20%, white); // use vendor prefixes for production code
}
You can then play around with the padding and background gradient to get a more stylish presentation.