【问题标题】:How can i make font-weight bold in input filed without changing the placeholder font-weight?如何在不更改占位符字体粗细的情况下在输入字段中将字体粗细设为粗体?
【发布时间】:2021-05-28 00:37:07
【问题描述】:

如果我想让输入字段的文本加粗而不是占位符,我应该怎么做?

如果我在输入字段中给出“font-weight:bold”,输入字段的占位符也会变为粗体。我希望输入字段的文本是粗体,而不是占位符

【问题讨论】:

  • input::placeholder{font-weight:normal;}

标签: css


【解决方案1】:

使用伪元素::placeholder。大多数现代浏览器都应该支持。

input {
  font-weight: bold;
}

input::placeholder {
  font-weight: 400;
}
<input placeholder="Type Here"/>

【讨论】:

  • 部分浏览器版本不支持但没问题。它对我有用。
猜你喜欢
  • 2017-01-20
  • 2014-07-16
  • 2018-05-07
  • 1970-01-01
  • 2011-12-05
  • 1970-01-01
  • 1970-01-01
  • 2019-12-27
  • 2015-11-14
相关资源
最近更新 更多