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

匿名 (未验证) 提交于 2019-12-03 02:03:01

问题:

I was under the impression that inline elements could not have their heights resized, but I am able to do so with elements.

Am I correct that elements are inline?

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

回答1:

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



回答2:

There is a difference between inline and inline-block.

You can change the height of the inline-block meanwhile you can't change the inline elements.

So I think what ever the thing you have changed might be an inline-block element.

Here is a Fiddle for you!



回答3:

They're rendered as inline-block per default. This is why you can specify a width. You can see this in chrome dev tools for example.

http://codepen.io/johannesjo/pen/BrcuE



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!