html - 带输入的文本框太小
问题描述
我正在尝试制作一个搜索文本输入框,其中输入文本的大小、字体和样式与占位符相同。
在互联网上搜索几乎找不到正确的方向。
这是我的代码:
::placeholder {
color: rgba(255, 255, 255, 0.8);
font-family: Moon;
font-size: 20px;
padding-left: 5%;
}
<input type="text" placeholder="Search..." name="searchInput" id="searchBar"><br />
当您继续键入文本时,它应该具有与占位符相同的样式。
解决方案
这是一个最小的示例,必须将所有属性添加到input
,并且仅设置 的颜色placeholder
。
input {
background: black;
color: rgba(255, 255, 255, 0.8);
font-family: Courier;
font-size: 20px;
padding-left: 5%;
padding-top: 2%;
padding-bottom: 2%;
}
::-webkit-input-placeholder {
/* WebKit, Blink, Edge */
color: rgba(255, 255, 255, 0.8);
}
:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
color: rgba(255, 255, 255, 0.8);
opacity: 1;
}
::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: rgba(255, 255, 255, 0.8);
opacity: 1;
}
:-ms-input-placeholder {
/* Internet Explorer 10-11 */
color: rgba(255, 255, 255, 0.8);
}
::-ms-input-placeholder {
/* Microsoft Edge */
color: rgba(255, 255, 255, 0.8);
}
::placeholder {
/* Most modern browsers support this now. */
color: rgba(255, 255, 255, 0.8);
}
<input type="text" placeholder="Search..." name="searchInput" id="searchBar">
推荐阅读
- javascript - 如何为无序列表中的每个列表项添加一个按钮?
- javascript - 多次调用的函数反应原生
- python - 如何访问外部数据帧中的数据以带回主数据帧 Pandas
- asp.net-mvc-4 - 关于为什么模板/小部件不会在开发站点上更新的任何想法?它适用于我的本地机器
- r - 如何在ggplot R的facetwrap中创建带有自定义标签的辅助轴
- java - JFrame 上的 MouseListener 永远不会被调用
- latex - 乳胶对齐语法
- firebase - 即使我取消链接,电话仍然有价值(firebase)
- pyspark - Pyspark:过滤数据帧并将函数应用于偏移时间
- javascript - 将 Bootstrap JavaScript 添加到 Docusaurus 但有问题