最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Change angular material input style - Stack Overflow

programmeradmin6浏览0评论

I am trying to change the style of a angular material input.

So far I managed to change the background-color using :

md-input-container {
    padding-bottom: 5px;
    background-color: #222;
}

The placeholder and label color using :

md-input-container.md-default-theme label,   
md-input-container.md-default-theme .md-placeholder {  
    color: #FDFE67 !important; 
} 

But I can't manage to change the line color under the text when we focus the input and the text color when we type in the input.

Here is the html input :

<md-content>
    <md-input-container>
        <label>{{isEnglish ? 'Search...' : 'Recherche...'}}</label>
           <input ng-model="searchInput" id="sInput" 
                  ng-change="filterCartoList(searchInput)" my-enter="filterCartoList(searchInput)">
    </md-input-container>
</md-content>

Edit: I managed to change the text color when typing this way :

md-input-container .md-input {
color: rgba(255,255,255,0.87);
border-color: rgba(254,253,103,0.82);
}

I am trying to change the style of a angular material input.

So far I managed to change the background-color using :

md-input-container {
    padding-bottom: 5px;
    background-color: #222;
}

The placeholder and label color using :

md-input-container.md-default-theme label,   
md-input-container.md-default-theme .md-placeholder {  
    color: #FDFE67 !important; 
} 

But I can't manage to change the line color under the text when we focus the input and the text color when we type in the input.

Here is the html input :

<md-content>
    <md-input-container>
        <label>{{isEnglish ? 'Search...' : 'Recherche...'}}</label>
           <input ng-model="searchInput" id="sInput" 
                  ng-change="filterCartoList(searchInput)" my-enter="filterCartoList(searchInput)">
    </md-input-container>
</md-content>

Edit: I managed to change the text color when typing this way :

md-input-container .md-input {
color: rgba(255,255,255,0.87);
border-color: rgba(254,253,103,0.82);
}
Share Improve this question edited Sep 15, 2015 at 12:58 Ellone asked Sep 15, 2015 at 11:54 ElloneEllone 3,89812 gold badges47 silver badges77 bronze badges 2
  • make a fiddle, this way is not clear and cannot help – Kristijan Iliev Commented Sep 15, 2015 at 12:08
  • Just change the color of existing material input we can find there : material.angularjs/latest/#/demo/material.ponents.input After seing their example, "line color under the text when we focus the input and the text color when we type in the input." should be more clear to you, you can directly export their example to codepen. I also added the html input in the question – Ellone Commented Sep 15, 2015 at 12:50
Add a ment  | 

2 Answers 2

Reset to default 10

This is the CSS selector used by Angular Material:

md-input-container:not(.md-input-invalid).md-input-focused .md-input {
    border-color: your_color_here;
}
<md-input-container style="position: relative; top:19px;">
                              <label style="border-color: white; color: white;">Email</label>
                              <input style="border-color: white; color: white;" >
                              </md-input-container>
发布评论

评论列表(0)

  1. 暂无评论