Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. CSS question about text trimming

CSS question about text trimming

Scheduled Pinned Locked Moved ASP.NET
questioncsstutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _iobuf
    wrote on last edited by
    #1

    Hi, I am trying to add an elipsis for some text inside a div using css. for example, <div style="???????"> WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW </div> What I want is for the end result to look like: WWWWWW... Or at least just cut off without the .... The div is inside a td which stretches out when the text is too long, and making the td or div a fixed width is not an option. How can I do this? Thanks!

    A 1 Reply Last reply
    0
    • _ _iobuf

      Hi, I am trying to add an elipsis for some text inside a div using css. for example, <div style="???????"> WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW </div> What I want is for the end result to look like: WWWWWW... Or at least just cut off without the .... The div is inside a td which stretches out when the text is too long, and making the td or div a fixed width is not an option. How can I do this? Thanks!

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      For width issue, you can set overflow property to hidden in style attribute. <div id="myDiv" style="overflow:hidden; height:20px; width:200px;"> Some Long Text. </div> If you wish to trim the text, use some javascript function on page load at client side.

      function Trim(id, len) {
      document.getElementById(id).innerHTML = document.getElementById(id).innerHTML.substring(0, len) + "...";
      }

      Hope this will help.

      Anurag Gandhi.
      http://www.gandhisoft.com
      Life is a computer program and every one is the programmer of his own life.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups