Skip to content

Commit

Permalink
[style] Fix placeholder should be hidden on focus
Browse files Browse the repository at this point in the history
The placeholder is currently visible on key focus and only hidden
once a user starts typing. This can be confusing and doesn't look
good.

As it turns out, ::placeholder is an official selector:
https://developer.mozilla.org/en-US/docs/Web/CSS/::placeholder

For some reason, listing placeholder selectors with "," doesn't
work on some browsers (tested in FF 60 ESR). Making each of the
selectors explicit works, however.
  • Loading branch information
logmanoriginal committed Jun 8, 2019
1 parent 8445037 commit f28cbec
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ input[type="number"]:focus {
border-color: #888;
}

input:focus::-webkit-input-placeholder { opacity: 0; }
input:focus::-moz-placeholder { opacity: 0; }
input:focus::placeholder { opacity: 0; }
input:focus:-moz-placeholder { opacity: 0; }
input:focus:-ms-input-placeholder { opacity: 0; }

.searchbar {
width: 40%;
margin: 40px auto 100px;
Expand All @@ -101,13 +107,6 @@ input[type="number"]:focus {
text-align: center;
}

.searchbar input[type="text"]:focus::-webkit-input-placeholder,
.searchbar input[type="text"]:focus::-moz-placeholder,
.searchbar input[type="text"]:focus:-moz-placeholder,
.searchbar input[type="text"]:focus:-ms-input-placeholder {
opacity: 0;
}

.searchbar > h3 {
font-size: 200%;
font-weight: bold;
Expand Down

0 comments on commit f28cbec

Please sign in to comment.