【问题标题】:Angular Material Md-toolbar InputAngular Material Md-工具栏输入
【发布时间】:2018-06-14 04:52:20
【问题描述】:

有没有办法像这样在 md-toolbar 中添加 md-input-container?

【问题讨论】:

    标签: input angularjs-material


    【解决方案1】:

    这很简单。只需将md-input-container 添加到工具栏中即可。

    <md-toolbar class="myCustomClass">
      <div class="md-toolbar-tools">
        <md-input-container class="md-block" flex-gt-sm>
          <label>Search for item</label> 
          <input ng-model="searchPhrase" name="searchPhrase">
        </md-input-container>
      </div>
    </md-toolbar>
    

    如果搜索框较高,您可能需要调整垂直对齐方式。您可以通过添加以下 css 来做到这一点:

    .myCustomClass md-input-container .md-errors-spacer{
      min-height: 0px !important;
    }
    

    显然正确的方法是为工具栏中的输入创建一个自定义类并应用上述样式,这样您就不会覆盖其他输入标签的默认样式。

    【讨论】:

    • 谢谢我错过了标签下的 部分。您将如何创建您所指的自定义类?
    • @Flash - 更新了我的答案。只需将自定义类添加到 md-toolbar 标记,然后确保更新 css 以利用此继承。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 2015-06-16
    • 1970-01-01
    • 2016-04-15
    • 1970-01-01
    • 2016-07-11
    • 1970-01-01
    相关资源
    最近更新 更多