-1

How can I display my text with dots when I resize the browser window using CSS ?

Eg:

My text

'Hello world! Welcome to Coding'

After resizing

Hello world! Welcome to Co...

Hello world! Welcome t... (Would display dots according to resizing of window)

Jane Fred
  • 1,379
  • 7
  • 23
  • 47

3 Answers3

0

Try this CSS.

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
0

You can archive this using text-overflow: ellipsis;overflow: hidden;white-space: nowrap;

For more information go to: text-overflow

Let me know if you have a any question about this.

Hope this help you

    .app a {
  width: 140px;
  padding: 0;
  overflow: hidden;
  position: relative;
  display: inline-block;
  margin: 0 5px 0 5px;
  text-align: center;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #000;
}
<div class="app">
  <a href="">Hello world! Welcome to Coding</a>
</div>
jaydeep patel
  • 867
  • 4
  • 14
0

Below is a basic example of how to use text-overflow: ellipsis;. You need the overflow: hidden; property to be present as well as white-space: nowrap;

HTML: <p class="overflow"> this text will not wrap and will show the ellipsis when it is wider than the screen width</p>

CSS:

.overflow {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
Brice
  • 86
  • 4