Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
728 views
in Technique[技术] by (71.8m points)

html - Why can input elements be sized if they are inline elements?

I was under the impression that inline elements could not have their heights resized, but I am able to do so with <input type="text"/> elements.

Am I correct that <input type="text"/> elements are inline?

If so, what makes them different from <span></span> elements in how they can or cannot be resized.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

An input element is inline-block by default, not inline.

On the other hand, an element such as a span, is inline by default.

The width/height of an inline-block element, such as input can be changed (example).

While an inline element, for instance, span, cannot be changed by default, as its dimensions are defined by the "rendered content within them". (example).

This [width] property does not apply to non-replaced inline elements. The content width of a non-replaced inline element's boxes is that of the rendered content within them (before any relative offset of children). Recall that inline boxes flow into line boxes. The width of line boxes is given by the their containing block, but may be shorted by the presence of floats. - W3 reference


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...