html - 使用 CSS 在文本输入中设置光标样式

标签 html css stylesheet

我正在为搜索栏设计表单

enter image description here

这是 HTML

<form class="search-form" action="index_submit" method="get" accept-charset="utf-8">
  <input type="search" name="search" placeholder="Search here...">
  <button type="submit"><i class="fa fa-search"></i></button>
  <div class="clearfix"></div>
</form>

这是我的 CSS

.search {
   position: static;
}

.search-box {
   position: absolute;
   top: 50%;
   left: 50%;
}

.search-form input[type="search"] , .search-form button {
   outline: none;
   border: none;
   padding: 10px;
   margin: 0;
   float: left;
   color: black;
}

.search-form input {
   background-color: yellow;
}

.search-form button {
   text-align: center;
}

我遇到了光标在该文本字段中闪烁的问题。我希望光标正好垂直居中对齐。我已经给出了填充,但它不起作用。我希望 CSS 自定义该光标。 谢谢。

最佳答案

尝试将“text-align: center”添加到您的搜索栏输入样式。我不确定你是不是想要它所以光标不显示?如果那是您的意思,请查看此链接。

Hide textfield blinking cursor

关于html - 使用 CSS 在文本输入中设置光标样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26322687/

相关文章:

php - 从代码库中删除无用文件

python - 如何在 Scrapy 中使用 response.XPath 从多个标签中提取文本数据?

html - 如何从表格的悬停中排除悬停的 td?

android - 如何在 Android 中将 CSS 样式代码应用到我的自定义 TextView 中

javascript - jquery:在运行时创建/读取 .css 样式

html - 在单个页面上的不同部分标签上应用不同的 css 样式文件

html - 3列表作为DIV

javascript - 如何滚动到父 iframe 的顶部按下 iframe 内的按钮?

css - 通过 CSS3 制作动画

css - SVG 作为网站导航栏的 CSS 背景