css - ionic 2 : How to overwrite the style of ionic component

标签 css ionic-framework sass ionic2

我是Ionic 2新手,请问如何改变ionic组件的样式?

我遇到了如下图所示的问题:

<form action="">
    <ion-list>
        <ion-item>
            <ion-label fixed>Username</ion-label>
            <ion-input type="text" value="" clearInput></ion-input>
        </ion-item>

        <ion-item>
            <ion-label fixed>Password</ion-label>
            <ion-input type="password" clearInput></ion-input>
        </ion-item>
    </ion-list>
</form>

布局将呈现为: enter image description here

每一项之间有3条灰线,长的是ion-list的,短的是ion-item的。

我试图覆盖theme/variables.scss中的样式,但似乎没有设置。

我在chrome里面看的很深,发现html是这样的 enter image description here

我不认为覆盖“.list-ios .item-block .item-inner”的样式是个好主意,还有其他方法可以解决这个问题吗?

谢谢。

最佳答案

你只需要给 no-lines在这个元素上<ion-list> . Doc about it .

像这样:Working Plunker

<ion-list no-lines>

  <ion-item>
    <ion-label fixed>Username</ion-label>
    <ion-input type="text"></ion-input>
  </ion-item>

  <ion-item>
    <ion-label fixed>Password</ion-label>
    <ion-input type="password"></ion-input>
  </ion-item>

</ion-list>

如果您需要了解如何在 Ionic2 上更改默认值,我强烈建议您阅读这篇文章。 A Guide to Styling an Ionic 2 Application

您不需要使用 !import如果您在页面组件内使用如下所示的样式,则进行 hack。使用 .ios,.md像这样:

登录.scss

 .ios,
    .md {
        page-login {
            .margin-top-35 {
                margin-top: 35px;
            }
         }
 }

关于css - ionic 2 : How to overwrite the style of ionic component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42968467/

相关文章:

javascript - Ionic 4 ion-select 为选择图标设置自定义图标

ruby-on-rails - SASS中每隔一行的背景色

css - 执行休息;在 SCSS 中

css - 如何使用 css 将两种不同的颜色放在标题后面?

html - 使用 flexbox(无 float )或其他任何方式将元素包裹在图像周围

JavaScript 错误 'cannot read property of undefined'

java - Android Studio、Core Java 中的 Ionic 应用程序开发

javascript - 选择的 Jquery 在 Rails 4 应用程序上无法正常工作

ionic-framework - ionic 载玻片 : vertical align content in center of slide. 如何?

javascript - Angular CLI 7 : Sass failed to compile