1

我正在使用材料设计精简版并尝试将内容对齐左/右/中心。但是无法执行它。这是代码

 <div class="mdl-card__actions mdl-card--border">

                    <button id="share-menu" class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect pull-left">
                        <i class="material-icons">share</i>
                    </button>
                    <ul class="mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect"
                        for="share-menu">
                        <li class="mdl-menu__item">Some Action</li>
                        <li class="mdl-menu__item mdl-menu__item--full-bleed-divider">Another Action</li>
                        <li disabled class="mdl-menu__item">Disabled Action</li>
                        <li class="mdl-menu__item">Yet Another Action</li>
                    </ul>
                    <span class="mdl-chip mdl-chip--contact center-block">
                        <span class="mdl-chip__contact mdl-color--teal mdl-color-text--white">12</span>
                        <button class="mdl-button mdl-button--icon mdl-button--colored"><i class="material-icons">thumb_up</i></button>
                    </span>
                    <button class="mdl-button mdl-button--icon mdl-button--colored pull-right"><i class="material-icons">add_shopping_cart</i></button>
                </div>

我尝试了 center-text , mdl-typography--text-center 类,但设计并不完美这里是屏幕截图

中心格

拉左和拉右工作但中心不工作。我怎样才能做到这一点?

4

1 回答 1

1

它会工作尝试它:

.mdl-card__actions {text-align:center;} /* will make the text in center */
.mdl-chip--contact {display: inline-block; float: none;} /* because it is inline-block it will be affected by text-align property in parent element */
于 2017-07-18T05:32:22.937 回答