HTML元素默认为display:inline-block? [英] HTML element which defaults to display:inline-block?

查看:897
本文介绍了HTML元素默认为display:inline-block?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< div> 默认为阻止

< span> 默认为 inline

有一个默认为 inline-block

如果没有,使用CSS应用'inline-block'?

或者我应该坚持使用类吗?

If not, what special tag name would be appropriate for me to apply 'inline-block' using CSS?
Or should I stick to using a class?

推荐答案

从我可以告诉的< img> 标签是唯一 inline-block 为了安全的一面,我会推荐一个类,你永远不知道,当改变某一类型的所有元素会回来咬你。或者,你总是可以组成你自己的标签,并分配 display:inline-block; 。这样,您就不会更改标准元素的默认功能...

From what I can tell the <img> tag is the only inline-block by default. To be on the safe side I would recommend a class, you never know when changing all elements of a certain type will come back to bite you. Or, you could always make up your own tag and assign display:inline-block; to it. This way you aren't changing the default functionality of standard elements...

EDIT

它还显示按钮 textarea 输入选择元素也 inline-block

It also appears that button, textarea, input, and select elements are also inline-block

来源:

根据 img inline-block http://dev.w3.org/html5/markup/img.html#img - 显示

这里声称按钮 textarea 等等: http://www.w3.org/TR/CSS2/sample .html

编辑#2

声称 img 标签 inline-block 似乎(感谢Alohci)他们只是内联 http://jsfiddle.net/AQ2yp/

While the source above claims that img tags are inline-block it seems (thanks to Alohci) that they are just inline http://jsfiddle.net/AQ2yp/

以下是在Firefox中测试的:

The following were tested in Firefox:

按钮 inline-块 http://jsfiddle.net/GLS4P/

textarea inline http://jsfiddle.net/235vc/

输入 inline http://jsfiddle.net/RFKe8/

select 是 inline-block http://jsfiddle.net/5B4Gs/

这篇关于HTML元素默认为display:inline-block?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆