【问题标题】:Sass and Compass Centering IssuesSass 和 Compass 居中问题
【发布时间】:2014-08-06 18:23:55
【问题描述】:

我还在学习 Sass、Compass 和 Susy,所以请多多包涵。我在将我的列表放在页脚中心时遇到了一点问题。它一直向左浮动。这是我正在使用的代码:

<footer>
<ul class="social">
    <li><a href="#"><i class="fa fa-facebook-square fa-3x"></i></a></li>
    <li><a href="#"><i class="fa fa-twitter-square fa-3x"></i></a</li>
    <li><a href="#"><i class="fa fa-instagram fa-3x"></i></a></li>
</ul>
<div class="copyright">&copy;2104 meylorodriguez.com<br />All Rights Reserved</div>
</footer>

这是我的 (s)CSS:

footer {

    ul.social {
        @include horizontal-list;
        background: $skyblue;
        padding: 4%;

        li a {
            color: $white;
        }       
    }

    .copyright {
        padding: 4%;
        text-align: center;
        font-family: 'Arbutus Slab', serif;
        font-size: small;
        color: $gray;
    }

}

我只需将三个社交媒体图标放在页脚的中心即可。

【问题讨论】:

  • 你看过水平列表混合实际上做了什么吗?

标签: sass compass-sass


【解决方案1】:

问题是horizontal-listfloat:left 添加到您的&lt;li&gt;s。所以,你总是有左边的列表。

有一种方法可以防止这种情况。如果您将display: inline-block 设置为&lt;ul&gt;,并将背景和对齐方式设置为&lt;footer&gt;,您就会明白这一点。

试试看:

footer {
  padding: 4%;
  background: blue;
  text-align: center;

  ul.social {
      @include horizontal-list;
      display: inline-block;

      li a {
         color: white;
      }       
  }

  .copyright {
    padding: 2% 4%;
    text-align: center;
    font-family: 'Arbutus Slab', serif;
    font-size: small;
    color: gray;
  }
}

希望对你有帮助。

问候。

编辑:为了测试它,我添加了我的自定义颜色值,你必须将其更改为你的

【讨论】:

  • 这修复了它。谢谢@mario。
  • 在这一点上,为什么还要使用水平列表混合呢?
  • 好吧,他需要查看居中对齐的水平列表。 mixin 效果很好,我只是添加了一些样式,以便按照 Meylo 的要求进行查看。
猜你喜欢
  • 1970-01-01
  • 2012-01-23
  • 2012-06-29
  • 2012-09-23
  • 2012-10-29
  • 1970-01-01
  • 2016-11-28
  • 1970-01-01
  • 2014-03-18
相关资源
最近更新 更多