【问题标题】:How do I center an image using jqmobile如何使用 jqmobile 使图像居中
【发布时间】:2012-02-13 21:54:38
【问题描述】:

嗨,我正在使用这段代码在 jquery mobile 中使图像居中,它使图像在 iphone 模拟器中居中,但是当我在 iphone 上检查时,它本身并没有完全居中(居中但不完全居中),而是倾向于向左.

<div data-role="content" data-theme="a">

   <div id="logo_image">
       <img src="images/logo.png"  alt="Image Header" >
   </div>

</div>

css 是

#logo_image {
  text-align: center;
  margin-left:0 auto;
  margin-right:0 auto;
}

提前谢谢...

【问题讨论】:

  • 在标题中加入“请尽快” A) 是噪音,B) 经常意味着 更少 人会阅读和回答您的问题。我已经为你删除了。

标签: jquery html css jquery-mobile


【解决方案1】:

只需尝试margin: 0 auto 而不是左右边距。之后您将能够设置顶部和底部边距。 问候

【讨论】:

    【解决方案2】:

    尝试将diplay: block 添加到您的图像中,它应该正确定位。

    【讨论】:

      【解决方案3】:

      这些其他答案部分正确,但为了使 margin: 0 auto 属性起作用,我相信您还必须为您的元素指定 width

      类似这样的:

      #logo_image {
        text-align: center;
        margin-left:0 auto;
        margin-right:0 auto;
        width: 80%; 
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-28
        • 2016-04-23
        • 2021-03-25
        • 2020-11-04
        相关资源
        最近更新 更多