admin管理员组文章数量:1355721
I am trying to set the width of a text input field as a percentage of total page width, as follows:
<input type="text" id="url" NAME="otherSite" size="70%" value=""/>
This doesn't seem to work. It seems I can specify the width of an input field only in absolute terms.
Short of going to javascript, is there any simple way? I am trying to have it look good both on desktop and mobile, where the windows are likely to be of very different size.
I am trying to set the width of a text input field as a percentage of total page width, as follows:
<input type="text" id="url" NAME="otherSite" size="70%" value=""/>
This doesn't seem to work. It seems I can specify the width of an input field only in absolute terms.
Short of going to javascript, is there any simple way? I am trying to have it look good both on desktop and mobile, where the windows are likely to be of very different size.
Share Improve this question asked Jul 20, 2011 at 2:20 LucaLuca 1,0681 gold badge11 silver badges17 bronze badges 1- Possible duplicate of Can the size of input fields be set to percent values? – Vadzim Commented May 28, 2017 at 18:37
1 Answer
Reset to default 6Use the style
attribute:
<input type="text" id="url" NAME="otherSite" style="width:70%" value=""/>
You also might want to read up on CSS (Cascading Style Sheets).
版权声明:本文标题:javascript - How to set the width of a text input field in a form to a percentage of page width? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744029261a2578607.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论