简体   繁体   中英

CSS Elastic textbox

My requirement is this. I need a text box with a width of 5px. As I type something on it the width should be increased. Is it possible to do using CSS only without js

thnx

ATM this is not possible with CSS only.

To achieve this you would have to check the current content width of the textfield on every keystroke in it (use the onKeyUp event of it) and then change the textbox' width accordingly.

hmm i only know like this one..

<script language="javascript">
function expand_textbox(s)
{
    s.size = s.size + 1;
}
</script>

<input type="text" size="20" name=txt onkeyup="expand_textbox(this)" >

try it..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM