【问题标题】:How do I make rounded button-group in Foundation 6?如何在 Foundation 6 中制作圆形按钮组?
【发布时间】:2016-02-21 09:02:09
【问题描述】:

Foundation 5 曾经有一个“圆形”类,可以将按钮组转换为圆形边缘。我如何在 Foundation 6 中做到这一点?

【问题讨论】:

    标签: zurb-foundation zurb-foundation-6


    【解决方案1】:

    在 Foundation 6 中这是不可能的。为了减小文件大小,这些规则已与其他规则一起被完全删除。最好的办法是将规则复制到 Foundation 6 css 文件或自定义 css 文件中(由您决定)。

    以下是您需要的 css 规则(直接取自最新的 Foundation 5 文件,没有任何改动):

    .button-group {
      list-style: none;
      margin: 0;
      left: 0; }
      .button-group:before, .button-group:after {
        content: " ";
        display: table; }
      .button-group:after {
        clear: both; }
      .button-group.even-2 li {
        display: inline-block;
        margin: 0 -2px;
        width: 50%; }
        .button-group.even-2 li > button, .button-group.even-2 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-2 li:first-child button, .button-group.even-2 li:first-child .button {
          border-left: 0; }
        .button-group.even-2 li button, .button-group.even-2 li .button {
          width: 100%; }
      .button-group.even-3 li {
        display: inline-block;
        margin: 0 -2px;
        width: 33.33333%; }
        .button-group.even-3 li > button, .button-group.even-3 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-3 li:first-child button, .button-group.even-3 li:first-child .button {
          border-left: 0; }
        .button-group.even-3 li button, .button-group.even-3 li .button {
          width: 100%; }
      .button-group.even-4 li {
        display: inline-block;
        margin: 0 -2px;
        width: 25%; }
        .button-group.even-4 li > button, .button-group.even-4 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-4 li:first-child button, .button-group.even-4 li:first-child .button {
          border-left: 0; }
        .button-group.even-4 li button, .button-group.even-4 li .button {
          width: 100%; }
      .button-group.even-5 li {
        display: inline-block;
        margin: 0 -2px;
        width: 20%; }
        .button-group.even-5 li > button, .button-group.even-5 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-5 li:first-child button, .button-group.even-5 li:first-child .button {
          border-left: 0; }
        .button-group.even-5 li button, .button-group.even-5 li .button {
          width: 100%; }
      .button-group.even-6 li {
        display: inline-block;
        margin: 0 -2px;
        width: 16.66667%; }
        .button-group.even-6 li > button, .button-group.even-6 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-6 li:first-child button, .button-group.even-6 li:first-child .button {
          border-left: 0; }
        .button-group.even-6 li button, .button-group.even-6 li .button {
          width: 100%; }
      .button-group.even-7 li {
        display: inline-block;
        margin: 0 -2px;
        width: 14.28571%; }
        .button-group.even-7 li > button, .button-group.even-7 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-7 li:first-child button, .button-group.even-7 li:first-child .button {
          border-left: 0; }
        .button-group.even-7 li button, .button-group.even-7 li .button {
          width: 100%; }
      .button-group.even-8 li {
        display: inline-block;
        margin: 0 -2px;
        width: 12.5%; }
        .button-group.even-8 li > button, .button-group.even-8 li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.even-8 li:first-child button, .button-group.even-8 li:first-child .button {
          border-left: 0; }
        .button-group.even-8 li button, .button-group.even-8 li .button {
          width: 100%; }
      .button-group > li {
        display: inline-block;
        margin: 0 -2px; }
        .button-group > li > button, .button-group > li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group > li:first-child button, .button-group > li:first-child .button {
          border-left: 0; }
      .button-group.stack > li {
        display: block;
        margin: 0;
        float: none; }
        .button-group.stack > li > button, .button-group.stack > li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.stack > li:first-child button, .button-group.stack > li:first-child .button {
          border-left: 0; }
        .button-group.stack > li > button, .button-group.stack > li .button {
          border-color: rgba(255, 255, 255, 0.5);
          border-left-width: 0;
          border-top: 1px solid;
          display: block;
          margin: 0; }
        .button-group.stack > li > button {
          width: 100%; }
        .button-group.stack > li:first-child button, .button-group.stack > li:first-child .button {
          border-top: 0; }
      .button-group.stack-for-small > li {
        display: inline-block;
        margin: 0 -2px; }
        .button-group.stack-for-small > li > button, .button-group.stack-for-small > li .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.stack-for-small > li:first-child button, .button-group.stack-for-small > li:first-child .button {
          border-left: 0; }
        @media only screen and (max-width: 40em) {
          .button-group.stack-for-small > li {
            display: block;
            margin: 0;
            width: 100%; }
            .button-group.stack-for-small > li > button, .button-group.stack-for-small > li .button {
              border-left: 1px solid;
              border-color: rgba(255, 255, 255, 0.5); }
            .button-group.stack-for-small > li:first-child button, .button-group.stack-for-small > li:first-child .button {
              border-left: 0; }
            .button-group.stack-for-small > li > button, .button-group.stack-for-small > li .button {
              border-color: rgba(255, 255, 255, 0.5);
              border-left-width: 0;
              border-top: 1px solid;
              display: block;
              margin: 0; }
            .button-group.stack-for-small > li > button {
              width: 100%; }
            .button-group.stack-for-small > li:first-child button, .button-group.stack-for-small > li:first-child .button {
              border-top: 0; } }
      .button-group.radius > * {
        display: inline-block;
        margin: 0 -2px; }
        .button-group.radius > * > button, .button-group.radius > * .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.radius > *:first-child button, .button-group.radius > *:first-child .button {
          border-left: 0; }
        .button-group.radius > *,
        .button-group.radius > * > a,
        .button-group.radius > * > button,
        .button-group.radius > * > .button {
          border-radius: 0; }
        .button-group.radius > *:first-child, .button-group.radius > *:first-child > a, .button-group.radius > *:first-child > button, .button-group.radius > *:first-child > .button {
          -webkit-border-bottom-left-radius: 3px;
          -webkit-border-top-left-radius: 3px;
          border-bottom-left-radius: 3px;
          border-top-left-radius: 3px; }
        .button-group.radius > *:last-child, .button-group.radius > *:last-child > a, .button-group.radius > *:last-child > button, .button-group.radius > *:last-child > .button {
          -webkit-border-bottom-right-radius: 3px;
          -webkit-border-top-right-radius: 3px;
          border-bottom-right-radius: 3px;
          border-top-right-radius: 3px; }
      .button-group.radius.stack > * {
        display: block;
        margin: 0; }
        .button-group.radius.stack > * > button, .button-group.radius.stack > * .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.radius.stack > *:first-child button, .button-group.radius.stack > *:first-child .button {
          border-left: 0; }
        .button-group.radius.stack > * > button, .button-group.radius.stack > * .button {
          border-color: rgba(255, 255, 255, 0.5);
          border-left-width: 0;
          border-top: 1px solid;
          display: block;
          margin: 0; }
        .button-group.radius.stack > * > button {
          width: 100%; }
        .button-group.radius.stack > *:first-child button, .button-group.radius.stack > *:first-child .button {
          border-top: 0; }
        .button-group.radius.stack > *,
        .button-group.radius.stack > * > a,
        .button-group.radius.stack > * > button,
        .button-group.radius.stack > * > .button {
          border-radius: 0; }
        .button-group.radius.stack > *:first-child, .button-group.radius.stack > *:first-child > a, .button-group.radius.stack > *:first-child > button, .button-group.radius.stack > *:first-child > .button {
          -webkit-top-left-radius: 3px;
          -webkit-top-right-radius: 3px;
          border-top-left-radius: 3px;
          border-top-right-radius: 3px; }
        .button-group.radius.stack > *:last-child, .button-group.radius.stack > *:last-child > a, .button-group.radius.stack > *:last-child > button, .button-group.radius.stack > *:last-child > .button {
          -webkit-bottom-left-radius: 3px;
          -webkit-bottom-right-radius: 3px;
          border-bottom-left-radius: 3px;
          border-bottom-right-radius: 3px; }
      @media only screen and (min-width: 40.0625em) {
        .button-group.radius.stack-for-small > * {
          display: inline-block;
          margin: 0 -2px; }
          .button-group.radius.stack-for-small > * > button, .button-group.radius.stack-for-small > * .button {
            border-left: 1px solid;
            border-color: rgba(255, 255, 255, 0.5); }
          .button-group.radius.stack-for-small > *:first-child button, .button-group.radius.stack-for-small > *:first-child .button {
            border-left: 0; }
          .button-group.radius.stack-for-small > *,
          .button-group.radius.stack-for-small > * > a,
          .button-group.radius.stack-for-small > * > button,
          .button-group.radius.stack-for-small > * > .button {
            border-radius: 0; }
          .button-group.radius.stack-for-small > *:first-child, .button-group.radius.stack-for-small > *:first-child > a, .button-group.radius.stack-for-small > *:first-child > button, .button-group.radius.stack-for-small > *:first-child > .button {
            -webkit-border-bottom-left-radius: 3px;
            -webkit-border-top-left-radius: 3px;
            border-bottom-left-radius: 3px;
            border-top-left-radius: 3px; }
          .button-group.radius.stack-for-small > *:last-child, .button-group.radius.stack-for-small > *:last-child > a, .button-group.radius.stack-for-small > *:last-child > button, .button-group.radius.stack-for-small > *:last-child > .button {
            -webkit-border-bottom-right-radius: 3px;
            -webkit-border-top-right-radius: 3px;
            border-bottom-right-radius: 3px;
            border-top-right-radius: 3px; } }
      @media only screen and (max-width: 40em) {
        .button-group.radius.stack-for-small > * {
          display: block;
          margin: 0; }
          .button-group.radius.stack-for-small > * > button, .button-group.radius.stack-for-small > * .button {
            border-left: 1px solid;
            border-color: rgba(255, 255, 255, 0.5); }
          .button-group.radius.stack-for-small > *:first-child button, .button-group.radius.stack-for-small > *:first-child .button {
            border-left: 0; }
          .button-group.radius.stack-for-small > * > button, .button-group.radius.stack-for-small > * .button {
            border-color: rgba(255, 255, 255, 0.5);
            border-left-width: 0;
            border-top: 1px solid;
            display: block;
            margin: 0; }
          .button-group.radius.stack-for-small > * > button {
            width: 100%; }
          .button-group.radius.stack-for-small > *:first-child button, .button-group.radius.stack-for-small > *:first-child .button {
            border-top: 0; }
          .button-group.radius.stack-for-small > *,
          .button-group.radius.stack-for-small > * > a,
          .button-group.radius.stack-for-small > * > button,
          .button-group.radius.stack-for-small > * > .button {
            border-radius: 0; }
          .button-group.radius.stack-for-small > *:first-child, .button-group.radius.stack-for-small > *:first-child > a, .button-group.radius.stack-for-small > *:first-child > button, .button-group.radius.stack-for-small > *:first-child > .button {
            -webkit-top-left-radius: 3px;
            -webkit-top-right-radius: 3px;
            border-top-left-radius: 3px;
            border-top-right-radius: 3px; }
          .button-group.radius.stack-for-small > *:last-child, .button-group.radius.stack-for-small > *:last-child > a, .button-group.radius.stack-for-small > *:last-child > button, .button-group.radius.stack-for-small > *:last-child > .button {
            -webkit-bottom-left-radius: 3px;
            -webkit-bottom-right-radius: 3px;
            border-bottom-left-radius: 3px;
            border-bottom-right-radius: 3px; } }
      .button-group.round > * {
        display: inline-block;
        margin: 0 -2px; }
        .button-group.round > * > button, .button-group.round > * .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.round > *:first-child button, .button-group.round > *:first-child .button {
          border-left: 0; }
        .button-group.round > *,
        .button-group.round > * > a,
        .button-group.round > * > button,
        .button-group.round > * > .button {
          border-radius: 0; }
        .button-group.round > *:first-child, .button-group.round > *:first-child > a, .button-group.round > *:first-child > button, .button-group.round > *:first-child > .button {
          -webkit-border-bottom-left-radius: 1000px;
          -webkit-border-top-left-radius: 1000px;
          border-bottom-left-radius: 1000px;
          border-top-left-radius: 1000px; }
        .button-group.round > *:last-child, .button-group.round > *:last-child > a, .button-group.round > *:last-child > button, .button-group.round > *:last-child > .button {
          -webkit-border-bottom-right-radius: 1000px;
          -webkit-border-top-right-radius: 1000px;
          border-bottom-right-radius: 1000px;
          border-top-right-radius: 1000px; }
      .button-group.round.stack > * {
        display: block;
        margin: 0; }
        .button-group.round.stack > * > button, .button-group.round.stack > * .button {
          border-left: 1px solid;
          border-color: rgba(255, 255, 255, 0.5); }
        .button-group.round.stack > *:first-child button, .button-group.round.stack > *:first-child .button {
          border-left: 0; }
        .button-group.round.stack > * > button, .button-group.round.stack > * .button {
          border-color: rgba(255, 255, 255, 0.5);
          border-left-width: 0;
          border-top: 1px solid;
          display: block;
          margin: 0; }
        .button-group.round.stack > * > button {
          width: 100%; }
        .button-group.round.stack > *:first-child button, .button-group.round.stack > *:first-child .button {
          border-top: 0; }
        .button-group.round.stack > *,
        .button-group.round.stack > * > a,
        .button-group.round.stack > * > button,
        .button-group.round.stack > * > .button {
          border-radius: 0; }
        .button-group.round.stack > *:first-child, .button-group.round.stack > *:first-child > a, .button-group.round.stack > *:first-child > button, .button-group.round.stack > *:first-child > .button {
          -webkit-top-left-radius: 1rem;
          -webkit-top-right-radius: 1rem;
          border-top-left-radius: 1rem;
          border-top-right-radius: 1rem; }
        .button-group.round.stack > *:last-child, .button-group.round.stack > *:last-child > a, .button-group.round.stack > *:last-child > button, .button-group.round.stack > *:last-child > .button {
          -webkit-bottom-left-radius: 1rem;
          -webkit-bottom-right-radius: 1rem;
          border-bottom-left-radius: 1rem;
          border-bottom-right-radius: 1rem; }
      @media only screen and (min-width: 40.0625em) {
        .button-group.round.stack-for-small > * {
          display: inline-block;
          margin: 0 -2px; }
          .button-group.round.stack-for-small > * > button, .button-group.round.stack-for-small > * .button {
            border-left: 1px solid;
            border-color: rgba(255, 255, 255, 0.5); }
          .button-group.round.stack-for-small > *:first-child button, .button-group.round.stack-for-small > *:first-child .button {
            border-left: 0; }
          .button-group.round.stack-for-small > *,
          .button-group.round.stack-for-small > * > a,
          .button-group.round.stack-for-small > * > button,
          .button-group.round.stack-for-small > * > .button {
            border-radius: 0; }
          .button-group.round.stack-for-small > *:first-child, .button-group.round.stack-for-small > *:first-child > a, .button-group.round.stack-for-small > *:first-child > button, .button-group.round.stack-for-small > *:first-child > .button {
            -webkit-border-bottom-left-radius: 1000px;
            -webkit-border-top-left-radius: 1000px;
            border-bottom-left-radius: 1000px;
            border-top-left-radius: 1000px; }
          .button-group.round.stack-for-small > *:last-child, .button-group.round.stack-for-small > *:last-child > a, .button-group.round.stack-for-small > *:last-child > button, .button-group.round.stack-for-small > *:last-child > .button {
            -webkit-border-bottom-right-radius: 1000px;
            -webkit-border-top-right-radius: 1000px;
            border-bottom-right-radius: 1000px;
            border-top-right-radius: 1000px; } }
      @media only screen and (max-width: 40em) {
        .button-group.round.stack-for-small > * {
          display: block;
          margin: 0; }
          .button-group.round.stack-for-small > * > button, .button-group.round.stack-for-small > * .button {
            border-left: 1px solid;
            border-color: rgba(255, 255, 255, 0.5); }
          .button-group.round.stack-for-small > *:first-child button, .button-group.round.stack-for-small > *:first-child .button {
            border-left: 0; }
          .button-group.round.stack-for-small > * > button, .button-group.round.stack-for-small > * .button {
            border-color: rgba(255, 255, 255, 0.5);
            border-left-width: 0;
            border-top: 1px solid;
            display: block;
            margin: 0; }
          .button-group.round.stack-for-small > * > button {
            width: 100%; }
          .button-group.round.stack-for-small > *:first-child button, .button-group.round.stack-for-small > *:first-child .button {
            border-top: 0; }
          .button-group.round.stack-for-small > *,
          .button-group.round.stack-for-small > * > a,
          .button-group.round.stack-for-small > * > button,
          .button-group.round.stack-for-small > * > .button {
            border-radius: 0; }
          .button-group.round.stack-for-small > *:first-child, .button-group.round.stack-for-small > *:first-child > a, .button-group.round.stack-for-small > *:first-child > button, .button-group.round.stack-for-small > *:first-child > .button {
            -webkit-top-left-radius: 1rem;
            -webkit-top-right-radius: 1rem;
            border-top-left-radius: 1rem;
            border-top-right-radius: 1rem; }
          .button-group.round.stack-for-small > *:last-child, .button-group.round.stack-for-small > *:last-child > a, .button-group.round.stack-for-small > *:last-child > button, .button-group.round.stack-for-small > *:last-child > .button {
            -webkit-bottom-left-radius: 1rem;
            -webkit-bottom-right-radius: 1rem;
            border-bottom-left-radius: 1rem;
            border-bottom-right-radius: 1rem; } }
    
    .button-bar:before, .button-bar:after {
      content: " ";
      display: table; }
    .button-bar:after {
      clear: both; }
    .button-bar .button-group {
      float: left;
      margin-right: 0.625rem; }
      .button-bar .button-group div {
        overflow: hidden; }
    

    Foundation 6 Fiddle

    【讨论】:

    • 很糟糕,他们删除了对它的原生支持。感谢您的解决方案!
    • 不客气。 Foundation 5 的很多功能都被删减了,这就是我没有切换到 Foundation 6 的原因。
    【解决方案2】:

    圆形按钮组实质上是分别对左侧和右侧的第一个和最后一个按钮进行四舍五入。

    HTML:

    <div class="button-group">
      <a class="button first">First</a>
      <a class="button">Middle</a>
      <a class="button last">Last</a>
    </div>
    

    SCSS:

    @mixin radius-left($radius) {
        border-radius-topleft:              $radius;
        border-radius-bottomleft:           $radius;
        -moz-border-radius-topleft:         $radius;
        -moz-border-radius-bottomleft:      $radius;
        -webkit-border-top-left-radius:     $radius;
        -webkit-border-bottom-left-radius:  $radius;
        -khtml-border-top-left-radius:      $radius;
        -khtml-border-bottom-left-radius:   $radius;
    }
    @mixin radius-right($radius) {
        border-radius-topright:             $radius;
        border-radius-bottomright:          $radius;
        -moz-border-radius-topright:        $radius;
        -moz-border-radius-bottomright:     $radius;
        -webkit-border-top-right-radius:    $radius;
        -webkit-border-bottom-right-radius: $radius;
        -khtml-border-top-right-radius:     $radius;
        -khtml-border-bottom-right-radius:  $radius;
    }
    ..
    ..
    .button.first { @include radius-left(10px); }
    .button.last  { @include radius-right(10px); }
    

    只需几行易于理解的行即可完全控制舍入。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-04
      相关资源
      最近更新 更多