How to set vertical alignment for mdRadioButton directive of Angular Material related to text?

断了今生、忘了曾经 提交于 2019-12-21 22:21:48

问题


How to set vertical alignment for mdRadioButton directive of Angular Material related to text? I have tried both layout-align and vertical-align style but, the radio button is always align middle related to the text.

here is the plunker

<md-content>
    <md-radio-group ng-model="data"  style="vertical-align:top;">
        <md-radio-button value="a" aria-label="Label 1" style="vertical-align:text-top;">long text 1</md-radio-button>
        <md-radio-button value="b"> long text 2 </md-radio-button>
    </md-radio-group>
</md-content>

回答1:


Angular Material actually generates a container for the radio button's on/off state and ripple.

<md-radio-button> is the parent and _md-container is the child element you want to modify.

Here's a fork of the plunker with the modified styles:

md-radio-button ._md-container {
    top: 0;
    transform: translateY(0);
}

Hope this helps!




回答2:


For Angular it can be achieved by:

mat-radio-button .mat-radio-label-content {
    white-space: normal;
}

mat-radio-button .mat-radio-label {
    align-items: normal;
}

Live Example: https://stackblitz.com/edit/angular-qkjhrz?embed=1&file=styles.css



来源:https://stackoverflow.com/questions/36893364/how-to-set-vertical-alignment-for-mdradiobutton-directive-of-angular-material-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!