How center a angularjs material card (md-card) vertically and horizontally? (Angular 1.x)

前端 未结 3 1510
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 05:04

I\'ve a problem I\'m sure would had a simple solution that I don\'t find. I\'m building a simple login page where I\'ve a angular material card (md-card) and nothing more. Insid

相关标签:
3条回答
  • 2021-01-21 05:32

    Here you go - CodePen

    • Column centered
      • Row centered, flex="50"
        • Card, flex="50"

    Markup

    <div ng-controller="AppCtrl" ng-cloak="" ng-app="MyApp" layout-fill layout="column" style="background:green" layout-align="center">
        <div flex="50" layout="row" layout-align="center">
          <md-card flex="50"></md-card>
        </div>
    </div>
    
    0 讨论(0)
  • 2021-01-21 05:32

    Finally, I found a simple way to do this:

    <div layout-fill layout="column" layout-align="center none">
        <div layout="row" layout-align="center none">
    
            <md-card>
    
                <md-card-title>
                    <md-card-title-text>
                        <span class="md-headline">Card title</span>
                    </md-card-title-text>
                </md-card-title>
    
                <md-card-content>
                    Card content
                </md-card-content>
    
            </md-card>
        </div>
    </div>
    
    0 讨论(0)
  • 2021-01-21 05:33

    You can try by setting dimensions of the element, and then adding:

    margin-left: auto;
    margin-right: auto;
    

    It should center this horizontally.

    0 讨论(0)
提交回复
热议问题