因为你有一个固定的高度,你可以使用absolute
位置来实现这一点(如果你不需要支持 IE 6)
编辑根据你的 jsfiddle 更新我的答案,但我现在只能在当前的 Chrome、Safari 和 FF 中测试它。
jsfiddle
要使自动放大功能与 FF 一起正常工作,您需要在其周围使用包装器,并且input
需要具有100%
. 为了防止input
要添加到以下 css 规则的元素的填充,width
需要使用:
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
box-sizing
支持:IE 8+、Chrome、Opera 7+、Safari 3+、Firefox
编辑
样式input
元素通常是有问题的,因为它们padding
和margin
. 要在没有 css3calc
功能的情况下获得想要的结果,您需要执行以下步骤:
定义周围的高度.form-wrapper
并将其设置为position
,relative
以便该元素负责absolute
其包含的元素的位置。
将容器 ( .input-wrapper
) 包裹在input
元素周围,将其位置定义为absolute
, left:0px
,top:0px
这样bottom:0px
包装器始终与右侧right:[the width of your button]
有一段距离。width of the button
将元素的width
and设置height
为。为了防止要添加到的元素的填充,您需要将 设置为。input
100%
input
width
box-sizing
border-box
将的位置设置为button
,absolute
并将宽度设置为top:0px
bottom:0px
right:0
width: [width of your button]