Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ellipsis on focused input

I have an input element with a placeholder which needs a CSS ellipsis. When there is no focus on the input, the ellipsis works correctly, but when I click on the input field, the ellipsis disappears and I see the full placeholder. How do I prevent that from happening?

like image 931
random_stuff Avatar asked Jun 17 '15 16:06

random_stuff


Video Answer


1 Answers

The browser's default functionality is to show the whole placeholder on focus and there is good reason for this.

The purpose of a placeholder is to give the user information about the field and as such every character should be available for the user to read, even if goes outside the box.

In your example (which I've edited here to demonstrate how to style placeholders) you can see that there is information in the placeholder that can never be seen - by viewing your field I'll just be left thinking 'Search intent names and display ... what'?

In fact, text-overflow: ellipsis; won't apply - it's block level and the placeholder can't be considered to have overflowed it's container because of it's nature (it's as big as it needs to be).

Some solutions:

  1. make the text field bigger.
  2. make the placeholder more concise (I'm guessing you could drop the 'and display examples').
  3. put the tip outside the field, by using a pop-up on focus, or just a line of text above or below.

All of these options put the user first, i.e. it's more important that the user has all the information they need clearly displayed and this sort of thing should inform the design and development decisions.

like image 90
Toni Leigh Avatar answered Oct 25 '22 05:10

Toni Leigh