简体   繁体   English

如何将Material Design Lite卡与右侧对齐

[英]How to align Material Design Lite cards to right hand side

I'm trying to build a simple page which have cards using material design lite components but one problem stucks the whole layout of the page. 我正在尝试构建一个简单的页面,其中包含使用精简设计的材料制作的卡片,但是一个问题卡住了页面的整个布局。 How to align the mdl card to right hand side of the screen ? 如何将MDL卡对准屏幕的右侧? I have tried by float:right; 我已经尝试过float:right; in css then the card is only shifting towards right in that same col not to the screen. 在CSS中,则该卡仅在同一列中向右移动,而不在屏幕上移动。 Help me to shift it 帮我转移

 <div class="mdl-cell mdl-cell--6-col"> <div class="demo-card-wide mdl-card mdl-shadow--2dp"> <div class="mdl-card__title"> <h2 class="mdl-card__title-text">Welcome</h2> </div> <div class="mdl-card__supporting-text"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sagittis pellentesque lacus eleifend lacinia... </div> <div class="mdl-card__actions mdl-card--border"> <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> Get Started </a> </div> <div class="mdl-card__menu"> <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"> <i class="material-icons">share</i> </button> </div> </div> </div> 

Try this class mdl-typography--text-right , in this way, the contents in that cell will have an alignment of right : 尝试此类mdl-typography--text-right ,以这种方式,该单元格中的内容将具有right的对齐方式:

<div class="mdl-cell mdl-cell--6-col mdl-typography--text-right">
    <div class="demo-card-wide mdl-card mdl-shadow--2dp">
        <div class="mdl-card__title">
            <h2 class="mdl-card__title-text">Welcome</h2>
        </div>
        <div class="mdl-card__supporting-text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit.
            Mauris sagittis pellentesque lacus eleifend lacinia...
        </div>
        <div class="mdl-card__actions mdl-card--border">
            <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
                Get Started
            </a>
        </div>
        <div class="mdl-card__menu">
            <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect">
                <i class="material-icons">share</i>
            </button>
        </div>
    </div>
</div>

Vice versa: mdl-typography--text-center and mdl-typography--text-left also work. 反之亦然: mdl-typography--text-centermdl-typography--text-left也可以。

Using an mdl-layout-spacer to the left of the card should help. 使用卡左侧的mdl-layout-spacer应该会有所帮助。 mdl-layout-spacer takes up as much space as it can. mdl-layout-spacer占用尽可能多的空间。

<div class="mdl-grid">
  <div class="mdl-layout-spacer"></div>
  <div class="mdl-cell mdl-cell--6-col">
    <div class="demo-card-wide mdl-card mdl-shadow--2dp">
      <div class="mdl-card__title">
        <h2 class="mdl-card__title-text">Welcome</h2>
      </div>
      <div class="mdl-card__supporting-text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Mauris sagittis pellentesque lacus eleifend lacinia...
      </div>
      <div class="mdl-card__actions mdl-card--border">
        <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
          Get Started
        </a>
      </div>
      <div class="mdl-card__menu">
        <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect">
          <i class="material-icons">share</i>
        </button>
      </div>
    </div>
  </div>
</div>

要对齐文本,请尝试使用: text-align:right;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM