【问题标题】:How to center elements using freetile.js?如何使用 freetile.js 使元素居中?
【发布时间】:2014-02-04 16:14:07
【问题描述】:

尝试了一些 CSS 修复,但似乎没有发生。很确定 freetile 脚本无论如何都会接管我的任何定位 css。

有什么想法吗?

http://jsfiddle.net/B35Hw/

编辑:text-align:center 似乎适用于小提琴,但不是我的网站,它几乎完全一样! :http://elijahhoffman.com/test

我的 CSS(在 Jsfiddle 的上下文之外不会有帮助):

#container {position:absolute;top:77px;width:100%;left:0px;}
#container img {height:100px;width:auto;padding:10px;margin:14px;opacity:1;              
                cursor:default; background-color:#fff;}

【问题讨论】:

    标签: jquery css jquery-plugins


    【解决方案1】:

    text-align: center; 添加到您的容器中

    在您的 #pcontainer img css 中,添加以下内容:

    display: inline-block !important;
    position: static !important;
    

    这为我解决了这个问题。问题是每个图像都设置为position: absolute,这会导致text-align: center 被忽略。

    【讨论】:

    • wth。我在我的实际布局上尝试了这个,但它没有工作 - 但它在小提琴上工作!加赫
    • @rootsup 可能有其他样式覆盖了您的 text-align: center。添加 !important 以防止它在某处被覆盖。
    • elijahhoffman.com/test - 它写在中间然后一切都向后移动......太奇怪了@Joel
    • @rootsup 我已更新答案以在您的实际页面上解决此问题
    • 太棒了,非常感谢!!为什么它可以在小提琴而不是我的页面上工作?即使它在那里设置为绝对?
    【解决方案2】:

    在我的情况下,text-align: center; 不起作用,这就是我改用 margin 的原因:

    #container {
    margin: 0 auto;
    width: 1000px;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-11
      • 2021-02-09
      • 2012-09-30
      • 2011-06-13
      • 2016-04-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多