【问题标题】:How to adjust the height of AngularJS Material Select Box?如何调整 AngularJS 材质选择框的高度?
【发布时间】:2016-12-29 03:33:39
【问题描述】:

我有以下代码

<md-input-container style="margin-right: 10px;width: 13%;"  class="ScenarioDetailsDropdown" >
        <h4    class="LabelsPageOne">Geography Type</h4>

        <md-select ng-model="GeographyType" ng-change="SelectGeographyType()" >
          <md-option   ng-repeat="(index,ModelTableRow) in ModelTable | unique:'geographyType'" ng-value="ModelTableRow.geographyType" >{{ModelTableRow.geographyType}}</md-option>
        </md-select>

</md-input-container>

如何降低选择框的高度? 另外,如何减少 md-input-container 中的顶部填充? 我试过用这个:

<md-input-container style="margin-right: 10px;width: 13%;" class="ScenarioDetailsDropdown" style="padding : 0px 0px !important;margin:0px 0px;" >

但是,它不起作用。 你能帮我做这个吗? 谢谢!

【问题讨论】:

    标签: angularjs angularjs-material


    【解决方案1】:

    您必须创建一个自定义指令以支持基于常规&lt;select&gt;&lt;/select&gt; 元素的此类自定义。不幸的是,Angular Materials md-select 元素不提供任何相关选项。

    【讨论】:

      【解决方案2】:

      这是你所追求的吗? CodePen

      标记

      <div ng-controller="AppCtrl" ng-cloak="" ng-app="MyApp" style="padding:100px">
        <md-input-container  class="ScenarioDetailsDropdown" >
          <h4 class="LabelsPageOne">Geography Type</h4>
          <md-select ng-model="GeographyType" ng-change="SelectGeographyType()" md-container-class="mySelect">
            <md-option   ng-repeat="(index,ModelTableRow) in ModelTable" ng-value="ModelTableRow.geographyType" >{{ModelTableRow.geographyType}}</md-option>
          </md-select>
        </md-input-container>
      </div>
      

      CSS

      .ScenarioDetailsDropdown {
        margin: 0;
        background: green
      }
      
      .ScenarioDetailsDropdown h4 {
        margin: 0;
      }
      
      .ScenarioDetailsDropdown md-select {
        background: white;
      }
      
      .ScenarioDetailsDropdown md-select md-select-value {
        height: 20px;
        min-height: 20px;
      }
      
      .mySelect {
        margin-top: 25px;
        margin-left: 20px;
      }
      

      【讨论】:

      • 嗨@camden_kid....非常感谢....我需要两件事...1。减少顶部的边距,2.减少白色选择框的高度....您已经向我展示了如何减少顶部的边距....所以这解决了我的问题。 1....你能告诉我如何减少白色选择框的高度吗?...谢谢!
      • @Sabyasachi 查看更新。特别是 md-select-value 的 CSS。
      猜你喜欢
      • 2018-06-10
      • 2017-01-20
      • 1970-01-01
      • 1970-01-01
      • 2022-11-28
      • 1970-01-01
      • 2021-04-21
      • 2021-11-30
      • 2018-06-09
      相关资源
      最近更新 更多