English 中文(简体)
Centering An Inline-Block DIV
原标题:Centering An Inline-Block DIV

Does anybody know how to center align a DIV that has the display set to inline-block?

由于我有需要重复的背景形象,而且需要根据内容加以扩大,我无法把展示放开。 它坐在母体内,当到血缘时,则更大。

因此,这一切都是如此。 是否有任何固定点能够把iv与固定锁的显示相匹配?

无,文字版:中心;不工作,也不差:零

jsFiddle: http://jsfiddle.net/HkvzM/

谢谢!

最佳回答

使用:

margin: 0 auto;

Or text-align: Center; on the parent <div>.

问题回答

亲爱的亲子关系中心不像儿童那样,

<>Cs

div{
    text-align: center;

}

.dl{
    color: #fff;
    margin: 0 auto;
    background: #000;
    text-transform: uppercase;
    font-size: 14px;
    font-weight: bold;  
    line-height:35px;  
    display:inline-block;    
}

<><><><>>><>>>>><>>>>>>>

<div>
<a class="dl">DOWNLOAD NOW DOWNLOAD NOW DOWNLOAD NOW</a>    
</div>

Live demo here

You can not center an element with

display:inline

你可能不得不利用 j或 Java本在周围找到工作。 如果案文不作长篇改动,你可以与安保部做一些大致的工作。 http://jsfiddle.net/HkvzM/16/“rel=“nofollow”

<div id="out">
    <a class="dl">DOWNLOAD NOW DOWNLOAD NOW DOWNLOAD NOW</a>
</div>​​​

#out{
 padding:0 50px;   
}

What I ve gotten from all of these (many, multitude, gobs of) answers is that you cannot center a block with an inline style call. It must be a defined class. Here s the canary:

<div
  style="font-size: 14pt; text-align: center; font-family: latoweb; font-weight: 400; display: inline-block; margin: 0 auto; width: 80%; height: auto;"
>
  <a
    id="media_comment_m-4JGUVJ6vm4uhihPBSiXrZGRG2Fm1a8To"
    data-media_comment_type="video"
    class="instructure_inline_media_comment video_comment mce-item-anchor"
    data-alt=""
  >
  </a>
  5 Quick Steps to <i>Photo Story 3</i>
</div>

Trying to center a video frame inside of Canvas LMS. Must pass their whitelist test.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签