【问题标题】:Style does not affect input in Ionic 3样式不影响 Ionic 3 中的输入
【发布时间】:2018-05-23 12:52:06
【问题描述】:

我正在尝试为我的应用创建登录页面。但是风格不像我希望的那样工作,这是问题的照片

1

这里是 login.html 代码

<ion-content class="app-content padding main-bg text-center">
  <div class="logo animated pulse infinite">
      <img src="../../assets/imgs/logo1.png" />
  </div>
  <form class="app-form">
      <div class="list list-inset">
          <label class="item item-input sec-main-text">
              <input type="text" class="text-center" placeholder="username">
          </label>
          <label class="item item-input sec-main-text">
              <input type="password" class="text-center" placeholder="Password">
          </label>
      </div>
      <button class="button button-block button-clear main-btn main-bg-color" ng-click="goto('/app/home')">Login</button>
      <a href="#/register" class="main-text-color">Register</a>
      <p class="forget" ng-click="forget_password()">Forget Password?</p>
  </form>
</ion-content>

这里是 login.scss 代码

 .app-form .list-inset {
    margin-left: 0;
    margin-right: 0;
    background: none;
  }

.app-form {
    .item-input {
      margin-bottom: 20px;
      background: none;
      border: 1px solid;
      border-radius: 30px;
      padding: 5px 10px;
    }
    .list-inset .item {
      border-radius: 30px;
      height: 46px;
      &.item-input input {
        padding: 0;
        color: white;
      }
    }
    input {
      &::-webkit-input-placeholder, &:-moz-placeholder {
        color: white;
        text-transform: capitalize;
      }
    }
  }


.app-form .item-select {
    select {
      width: 100%;
      max-width: 100%;
      background: none;
      text-align-last: center;
      padding: 0;
      text-align: -moz-center;
      text-align: -webkit-center;
      text-align-last: -moz-center;
      text-align-last: -webkit-center;
      direction: ltr;
    }
    &:after {
      top: 60%;
      right: 55px;
    }
  }

这就是我想要的原始 login.html :)

2

以及来自原始 html 的浏览器截图

3

从我的应用的浏览器截图

4

感谢您的帮助:)

编辑

After change html tags with ion tags

【问题讨论】:

    标签: html ionic-framework sass


    【解决方案1】:

    Ionic 引入并使用了自己的标签,例如,添加了默认样式。您似乎在应用程序中使用标准标签,例如 和 。将您的输入更改为

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

    事情会更顺利。

    Ionic 学起来很有趣,因为它很简单。访问Official Doc,了解如何让事情变得更简单。使用正确的语法,您将不会减少样式规则。

    【讨论】:

    • 很好的建议,白色文本框已经消失,谢谢 :) 但我仍然无法从页边距和文本中心获得操作。放置全宽的文本框,其文本从左侧开始。我需要额外的样式吗?
    • 阅读此处ionicframework.com/docs/theming/css-utilities。当然,您可以在必要时添加自定义样式。可以发一张当前输出的照片吗?
    猜你喜欢
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 2018-12-29
    • 2016-01-24
    • 2019-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多