5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コントリビューターが使ってるIonicデフォルトCSS

Posted at

英語よりも日本語のほうがフォントサイズが大きく見えることが多々あります。Web技術でモバイルアプリをつくることができるIonic Frameworkも例外ではなく、デフォルトテンプレートは英語では格好よくみえるのですが、テキストを日本語に入れ替えると少し野暮ったくみえがちです。

そこで、私はいつも以下を overwrite.scss として配置して、デフォルトのフォントサイズを上書きしています。これからデザインする方の参考になりましたら幸いです。

html {
  font-size: 90%;
}

ion-toolbar {
  --background: var(--ion-background-color) !important;
  & * {
    font-size: 1rem;
    font-weight: normal;
  }
  ion-buttons {
    * {
      font-size: 1rem !important;
    }

    ion-button ion-icon[slot=icon-only] {
      font-size: 1.2rem !important;
    }

    ion-back-button {
      font-size: 0.8rem !important;
    }

    ion-button[fill="outline"] {
      font-size: 0.9rem !important;
      max-height: 26px;
    }
  }
  ion-back-button {
    padding-left: 8px;
  }

  ion-segment {
    padding: 0;
  }
}

ion-alert {
  .alert-title, .alert-button {
    font-size: 1.1rem !important;
  }
  .alert-sub-title {
    font-size: 0.9rem !important;
  }
  .alert-message {
    padding-top: 8px !important;
    text-align: left !important;
    font-size: 1rem !important;

    &:empty {
      padding: 0 0 8px !important;
    }
  }
}

ion-action-sheet {
  .action-sheet-button {
    font-size: 1.05rem !important;
  }
}

/**
 * Alert作成時に `cssClass: 'alert-absolute',` が必要です
 */
.ios {
  .alert-absolute {
    position: absolute !important;
  }
}

/**
 * この設定は親に `default-font-size` が必要です
 */
.default-font-size {
  ion-input, ion-textarea, ion-label, ion-datetime, ion-select, ion-select-option, ion-note, ion-searchbar, input, textarea {
    font-size: 1rem !important;
  }
}


5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?