How to position elements to the right in md-toolbar?

后端 未结 2 1010
慢半拍i
慢半拍i 2021-01-31 02:41

I am using FAB speed dial within a toolbar. However I am unable to have it floating to the right of the toolbar. I\'ve tried float: right with no luck. Also, tried

相关标签:
2条回答
  • 2021-01-31 03:01

    THIS SOLUTION IS FOR ANGULAR MATERIAL v1.X, IF YOU NEED AN UNIVERSAL/ANGULAR MATERIAL v2 SOLUTION CHECK @experimenter ANSWER

    If you have a md-toolbar the easiest way to align right content is like this:

        <md-toolbar>
            <div class="md-toolbar-tools">
                <h3>You text</h3>
                <span flex></span>
                <ANY>your right content</ANY>
            </div>
        </md-toolbar>
    

    The flex property in span will cover the space between the contents. This is the official way in documentation.

    In you example, you just need:

    <md-toolbar>
        <div class="md-toolbar-tools">
            <div layout="row">
                <i class="fa fa-users fa-2x" flex></i>
                <h1 class="md-title" style="color:white">Org Chart</h1>
            </div>
            <span flex></span>
            <md-fab-speed-dial md-direction="left" ng-class="md-fling">
                <md-fab-trigger>
                    <md-button aria-label="menu" class="md-fab md-accent">
                        <md-tooltip>
                            Actions
                        </md-tooltip>
                        <md-icon md-svg-src="img/icons/ic_view_module_48px.svg"></md-icon>
                    </md-button>
                </md-fab-trigger>
                <md-fab-actions>
                    <md-button aria-label="view" class="md-fab md-raised md-mini">
                        <md-tooltip>
                            View Chart
                        </md-tooltip>
                        <md-icon md-svg-src="" style="color:black" ng-show="cDP.read" ng-click="paneShowFn('read')"></md-icon>
                    </md-button>
                    <md-button aria-label="add" class="md-fab md-raised md-mini">
                        <md-tooltip>
                            Add Chart
                        </md-tooltip>
                        <md-icon md-svg-src="img/icons/ic_add_48px.svg" style="color:black" ng-show="cDP.insert" ng-click="paneShowFn('insert')"></md-icon>
                    </md-button>
                    <md-button aria-label="Settings" class="md-fab md-raised md-mini">
                        <md-tooltip>
                            Security Access
                        </md-tooltip>
                        <md-icon md-svg-src="img/icons/ic_add_48px.svg" style="color:black" ng-show="cDP.permission" ng-click="paneShowFn('permission')"></md-icon>
                    </md-button>
                    <md-button aria-label="edit" class="md-fab md-raised md-mini" style="color:black" ng-show="cDP.update" ng-click="paneShowFn('update')">
                        <md-tooltip>
                            Edit Chart
                        </md-tooltip>
                        <md-icon md-svg-src="img/icons/ic_edit_48px.svg" style="color:black"></md-icon>
                    </md-button>
                </md-fab-actions>
            </md-fab-speed-dial>
        </div>
    </md-toolbar>
    
    0 讨论(0)
  • 2021-01-31 03:06

    Or you can use a class for that:

    .fill-space {
      // This fills the remaining space, by using flexbox.
      // Every toolbar row uses a flexbox row layout.
      flex: 1 1 auto;
    }
    <md-toolbar color="primary">
      <span>Application Title</span>
    
      <!-- This fills the remaining space of the current row -->
      <span class="fill-space"></span>
    
      <span>Right Aligned Text</span>
    </md-toolbar>

    This solution is also taken from a spec.

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