HTML truncate content based on div height

后端 未结 4 1890
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 21:21

I have a div with width of 130px a height of 200px.

Various text content gets displayed in this div (I\'ve written some JS to fade in and out differ

4条回答
  •  执念已碎
    2020-12-14 21:43

    I used dotdotdot jQuery plugin to solve a similar problem. Line breaks should not be an issue with dotdotdot but inserted images should have width and height atributes specified in html.

    If you are generating content dynamically you could determine image dimensions server-side (e.g. getimagesize function if you are using PHP). If this is not an option you can initialize dotdotdot inside $(window).load() but this will probably show content without ellipsis till all the media on the page is loaded.

提交回复
热议问题