html - CSS 过渡高度输入元素

标签 html css

我有一个输入元素,当用户在框中单击时,它会向右增长。

.search {
  display: inline-block;
  width: 20px;
  -webkit-transition: all .5s ease;
  -moz-transition: all .5s ease;
  transition: all .5s ease;
  text-align: left;
}
.search:focus {
  width: 250px;
  -webkit-transition: all .5s ease;
  -moz-transition: all .5s ease;
  transition: all .5s ease;
  text-align: left;
}
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
  <input class="search" type="search" value="" name="s" id="s">
</form>

想法是输入元素从 20px 增长到 250px。该问题与无法正常工作的过渡无关:-)

问题是输入框的高度非常小。无论我尝试什么,它都不会变大:

查看 Fiddle

最佳答案

您正在使用输入类型 search,它不接受高度。 但是添加 -webkit-appearance:textfield; 将允许您添加填充以增加高度,或手动设置高度。

关于html - CSS 过渡高度输入元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34657752/

相关文章:

javascript - 如何使用ajax post请求从输入中放入参数?

css - 谷歌地图半径 Angular

html - 将 Bootstrap 3 div 放在居中的 div 中以居中

html - 在表单操作属性中包含 GET 变量

javascript - 如何根据光标移动*到*的元素更改 jQuery .mouseleave() 的行为?

html - div 中垂直对齐的多行元素,溢出时滚动

html - 图像不使用 CSS 重新缩放

css - p :selectOneMenu error when wrap around by "display: inline-block" on IE 8

javascript - 如何返回上一页并在动画结束后恢复滚动位置?

javascript - 如何使用 javascript 异步移动多个叠加图像?