-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(css): update opacity example from ::placeholder #37480
base: main
Are you sure you want to change the base?
Conversation
Preview URLs Flaws (48)URL:
(comment last updated: 2025-01-03 07:44:14) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a third placeholder example instead of requiring un-commenting.
The inputs should have a <label>
{{EmbedLiveSample("default_color", 200, 60)}} | ||
|
||
> [!NOTE] | ||
> Note that browsers use different default colors for placeholder text. For example, Firefox uses the input element's color with 54% opacity, and Chrome uses `darkgray` color. If you want consistent placeholder text color across the browsers, then set the color explicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> Note that browsers use different default colors for placeholder text. For example, Firefox uses the input element's color with 54% opacity, and Chrome uses `darkgray` color. If you want consistent placeholder text color across the browsers, then set the color explicitly. | |
> Note that browsers use different default colors for placeholder text. For example, Firefox uses the input element's color with 54% opacity, and Chrome uses `darkgray` color. If you want consistent placeholder text color across the browsers, then set the `color` explicitly. |
<input placeholder="Default opacity" /> | ||
<input placeholder="Full opacity" class="force-opaque" /> | ||
<input placeholder="Color set by browser" /> | ||
<input placeholder="Same color as input" class="explicit-color" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<input placeholder="Same color as input" class="explicit-color" /> | |
<input placeholder="Same color as input" class="explicit-color" /> | |
<input placeholder="Semi-opaque text color" class="opacity-change" /> |
|
||
/* less opaque text */ | ||
/* color: color-mix(in srgb, currentColor 70%, transparent); */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* less opaque text */ | |
/* color: color-mix(in srgb, currentColor 70%, transparent); */ | |
} | |
.opacity-change::placeholder { | |
/* less opaque text */ | |
color: color-mix(in srgb, currentColor 70%, transparent); |
Now, it's about the opacity of the text color and not the element's background, so the
opacity
property shouldn't be used in the example.Let's explain the opacity of the color and default color separately.