text-overflow



значения свойства:


  • clip
  • ellipsis



css/style.css
  • div {
  •  width: 200px;
  •  height: 20px;
  •  border: 1px solid #8E8E8E;
  •  white-space: nowrap;
  • }
  •  
  • .a {
  •  overflow: hidden;
  •  text-overflow: clip;
  • }
div {
 width: 200px;
 height: 20px;
 border: 1px solid #8E8E8E;
 white-space: nowrap;
}

.a {
 overflow: hidden;
 text-overflow: clip;
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="a">
  •   But it was a dream. Three weeks ago, I had been lying on a beach
  •   in Hawaii. But I was not in Hawaii now.
  •  </div>
  •  <br />
  •  <div id="div1">
  •   But it was a dream. Three weeks ago, I had been lying on a beach
  •   in Hawaii. But I was not in Hawaii now.
  •  </div>
  •  <br />
  •  <div class="b">
  •   But it was a dream. Three weeks ago, I had been lying on a beach
  •   in Hawaii. But I was not in Hawaii now.
  •  </div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.overflow = "hidden";
  •  document.getElementById("div1").style.textOverflow = "ellipsis";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css({ "text-overflow": "ellipsis", "overflow": "hidden" });
  •  });
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="a">
  •   But it was a dream. Three weeks ago, I had been lying on a beach
  •   in Hawaii. But I was not in Hawaii now.
  •  </div>
  •  <br />
  •  <div id="div1">
  •   But it was a dream. Three weeks ago, I had been lying on a beach
  •   in Hawaii. But I was not in Hawaii now.
  •  </div>
  •  <br />
  •  <div class="b">
  •   But it was a dream. Three weeks ago, I had been lying on a beach
  •   in Hawaii. But I was not in Hawaii now.
  •  </div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.overflow = "hidden";
  •  document.getElementById("div1").style.textOverflow = "ellipsis";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css({ "text-overflow": "ellipsis", "overflow": "hidden" });
  •  });
  • </script>
  • </body>
  • </html>