如何在边框中心对齐两个项目?

时间:2015-02-06 16:54:33

标签: javascript html css sass

我写了这个css是为了将我的文本对齐到底部边框的中心 -

.arrow-down
  width: 2rem
  display: inline
  position: absolute
  top: -0.6rem
  left: 50%
  margin-left: -59px
  background: $grey_200
  z-index: 5

.showless
  > section
    width: 100%
    text-align: center
    border-bottom: 0.1rem solid $grey_300
    line-height: 0.1em
    margin: 1rem 0 2rem
    background: $grey_200
    > span
      width: 6rem
      margin-right: -5.6rem
      right: 56%
      position: absolute
      top: 0
      background: $grey_200
      padding: 0 10px
.showless
  position: relative
  .content
    overflow: hidden
    transition: all linear 0.5s
    -webkit-transition: all linear 0.5s
  .trigger
    display: inline-block
    cursor: pointer
    position: relative

我的HTML是

<div class="showless">
  <div ng-transclude class="content" ng-style="style">

  </div>
  <section class="trigger" ng-if="showSection" ng-click="toggleMore($event)">
    <i class="arrow-down"></i>
    <span>{{more ? "More":"Less"}}</span>
  </section>
</div>

最终看向中心。关于如何将向下箭头和更多文本放在中心的任何想法?看起来像这样 - off centered!

1 个答案:

答案 0 :(得分:2)

只需将text-align应用于该部分:

&#13;
&#13;
.trigger{
  text-align: center;
}
&#13;
<div class="showless">
  <div ng-transclude class="content" ng-style="style">

  </div>
  <section class="trigger" ng-if="showSection" ng-click="toggleMore($event)">
    <i class="arrow-down"></i>
    <span>{{more ? "More":"Less"}}</span>
  </section>
</div>
&#13;
&#13;
&#13;