我有一个文本框在我的HTML与白色底部边框聚焦时,我希望它改变宽度的文本字段的当前文本的长度(当然有一些限制)。我试过CSS最小宽度和最大宽度,但它似乎什么都不做。我认为用JS实现它需要一个硬编码的宽度表,我不想这样做。改变尺寸<input>
编辑:
这只是简单的CSS,但这里的代码:
#container {
width: 100%;
height: 52px;
background: #673ab7;
}
#textbox {
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
color: white;
background: none;
border: none;
vertical-align: top;
margin-top: 13px;
margin-left: 13px;
outline: none;
}
#textbox:focus {
border-bottom: 2px solid white;
}
<div id="container">
<input type="text" id="textbox" placeholder="placeholder" />
</div>
你的要价是有点不清楚什么。直到你开始输入,边框的宽度是输入的整个宽度吗?如果你想边界改变_as某人types_那么你将需要使用JS。 – hungerstar
@ hungerstar对不起,我的意思是文本框的宽度... – NieDzejkob