如何从 ionic 4 中的 ion-items 中删除白色背景?

How do I remove white background from ion-items in ionic 4?

我在设计 ionic 4 移动应用程序布局时遇到了很多问题。我花了一段时间才弄清楚如何为应用程序设置背景图像,但现在我在放置 ion-item 标签的任何地方都会得到一个白色矩形。我试过设置 ion-item {背景:透明重要!}(在页面 scss 中)但它不起作用。我是 ionic 的初学者!

register.page.scss

:host { ion-content {
--background:none;
background: url('../../assets/imgs/hoghi/bg.jpg')  no-repeat 100% 100%;
background-size: cover;
background-position: center center;

ion-item {
  background-color: transparent !important;
  background: transparent !important;
  opacity:1;
}//end of item}//end of content}//end of :host

register.page.html

<ion-content>
  <ion-item>
    <ion-label position="floating">Name</ion-label>
    <ion-input></ion-input> 
  </ion-item>
</ion-content>

您应该尝试使用 Shadow DOM 变量来实现。

可以使用这些变量自定义 Ionic 组件的样式。

Get more info for ion-item here

按照您的代码将是:

ion-item {
  --background: none;
  opacity:1;
}

More information on Shadow DOM

您总是可以在每个组件文档的页面末尾找到这些变量