居中图像 [英] Centering Images
问题描述
将图像居中于< div>是否合适?使用text-align:center
属性?或者有更好的方法吗?
Is it proper to center images in a <div> by using the text-align: center
property? Or is there a better way?
推荐答案
Heath写道:
将图像置于中心是否合适一个< div>使用text-align:center
属性?或者有更好的方法吗?
Is it proper to center images in a <div> by using the text-align: center
property? Or is there a better way?
取决于; display:block;,display:inline-block;,display:inline;?
-
Anne van Kesteren
< http://www.annevankesteren.nl/>
Depends; display:block;, display:inline-block;, display:inline;?
--
Anne van Kesteren
<http://www.annevankesteren.nl/>
对不起,默认显示:块
Anne van Kesteren写道:
Yeah sorry, the default display:block
Anne van Kesteren wrote:
Heath写道:
Heath wrote:
将图像置于< div>中心是否合适?使用text-align:
中心属性?或者有更好的方法吗?
Is it proper to center images in a <div> by using the text-align:
center property? Or is there a better way?
取决于; display:block;,display:inline-block;,display:inline;?
Depends; display:block;, display:inline-block;, display:inline;?
Heath写道:
Heath wrote:
对不起,默认显示:阻止
Yeah sorry, the default display:block
我认为默认情况下目前在大多数浏览器中都有点未分解,
,因为图片不会像< h2>那样强制换行。可以? ;-)
显示:inline-block;将是正确的语法,但大多数浏览器
可能有显示:内联;有一些额外的规则因此
text-align:center;会工作。
如果是真的,就像你说的那样(或者你自己也做过?)你将会b / b
必须使用保证金:0 auto;为了使图像居中,因为
''text-align''显然不适用于块级元素。
-
Anne van Kesteren
< http://www.annevankesteren.nl/>
I think the default is currently a bit ''undifined'' in most browsers,
since a image doesn''t force a line-break like a <h2> does it? ;-)
display:inline-block; would be the correct syntax, but most browsers
probably have display:inline; with some extra rules and therefore
text-align:center; will work.
If it is true, like you said (or perhaps you did it yourself?) you will
have to use margin:0 auto; in order to center the image, since
''text-align'' obviously doesn''t applies to block-level elements.
--
Anne van Kesteren
<http://www.annevankesteren.nl/>
这篇关于居中图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!