开发者

What is the value of 'auto' in the input field

<input name="Username" type="text" id="Username" width="auto" height="auto">

I want to know the val开发者_StackOverflowue of auto... the Integet value behind this.


Use javascript:

document.getElementById("Username").clientWidth

document.getElementById("Username").offsetWidth


There is no integer value behind it, it is a validity error. Input elements do not have a width (or a height) attribute, and no width attribute in HTML takes auto as a value.

The attributes will be ignored and the size of that element will be determined by the usual pattern of user stylesheet falling back to author stylesheet falling back to browser stylesheet.


<input name="Username" type="text" id="Username"  width="auto" height="auto">

<script>
alert(document.getElementById('Username').offsetWidth); //chrome and others
alert(document.all.Username.offsetWidth); // for ie and chrome
</script>


"Auto" is the default value of a text box height.

If you don't want to specify width or height of the textbox, HTML accepts auto as a value.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜