ionic 2에서 ion-title의 글꼴 색상 변경 (Change font color of ion-title in ionic 2)


문제 설명

ionic 2에서 ion‑title의 글꼴 색상 변경 (Change font color of ion‑title in ionic 2)

안녕하세요, 저는 ionic2에서 할 일 목록 앱을 만들고 있습니다. 사이드바 목록이 있습니다. list.html에 다음 코드가 있습니다.

<ion‑navbar *navbar>
  <a menu‑toggle>
    <icon menu></icon>
  </a>
  <ion‑title class="listTitle">My First List</ion‑title>
</ion‑navbar>

css를 사용하여 "My First List"의 색상을 흰색으로 변경하려고 합니다. 하지만 작동하지 않습니다. 또한 제목의 배경색을 정의했지만 메뉴 아이콘보다 우선합니다. 그 이유는 무엇입니까?

css:

.listTitle
{
    background‑color : #58B43F;
    color : #ffffff !important;
    box‑shadow : 0px 6px 10px #888888;
}

내 예상 결과는 탐색 모음이 흰색 제목과 흰색 메뉴 아이콘과 함께 녹색으로 표시된다는 것입니다. 어떻게 해야 하나요?

감사합니다.


참조 솔루션

방법 1:

Ionic 2 uses keywords to reference SASS variables from the app.variables.scss file, which can be added as attributes directly to tags. Using this we can change primary and secondary to green and white:

$colors: (
  primary:    #58B43F,
  secondary:  #fff,
  ...
);

For some reason it didn't work when I tried to apply the secondary colour attribute to the ion‑title tag, but a nested text tag works fine (e.g. <p>).

So, below is how these colour aliases are used to style ion‑navbar (note specifically where primary and secondary aliases are placed within the tag declarations):

<ion‑navbar primary *navbar>
  <a menu‑toggle>
    <icon menu></icon>
  </a>
  <ion‑title>
    <p secondary>My First List</p>
  </ion‑title>
</ion‑navbar>

EDIT: Other customisations

To adjust the navbar height, add these to app.variables.scss:

$toolbar‑ios‑height: 8rem; // ios
$toolbar‑md‑height: 8rem;  // android

To use a new font‑family, override the ion‑navbar style:

ion‑navbar {
  font‑family: 'MyFontFamily';
  text‑transform: uppercase;
  letter‑spacing: 0.14em; 
}

(by asafcourtness)

참조 문서

  1. Change font color of ion‑title in ionic 2 (CC BY‑SA 2.5/3.0/4.0)

#ionic #ionic-framework #ionic2






관련 질문

Cordova - OS 업그레이드 후 iOS/Android 모두에서 앱 충돌 (Cordova - app crashes on both iOS/Android after an OS upgrade)

모바일용 HTML 5의 특정 영역에 링크가 있는 이미지 (Image with links in certain areas in HTML 5 for mobile)

Play 스토어에서 오류 발생 - "이 앱은 모든 기기와 호환되지 않습니다." (Getting error from play store - “This app is incompatible with all of your devices.”)

div의 오른쪽 하단에 이온 버튼 정렬 (Align an ionic button at the bottom right of a div)

새로운 Xcode 프로비저닝 정책 및 Ionic Framework (New Xcode provisioning policy and Ionic Framework)

각도 [$injector:unpr] 알 수 없는 공급자 오류를 해결하는 방법? (How to solve angular [$injector:unpr] Unknown provider error?)

ionic, 팝오버 범위에 범위 변수 전달 (ionic, pass scope variable to popover scope)

Angular: 2필드 데이터 바인딩 문제 (Angular: issue with two-field data binding)

ionic 2에서 ion-title의 글꼴 색상 변경 (Change font color of ion-title in ionic 2)

PhoneGap 빌드가 내 모든 파일을 업데이트하지 않습니다. (PhoneGap build is not updating all of my files)

Ionic 빌드 Android를 수행하는 동안 오류가 발생했습니다. (Error while doing Ionic build android)

$ionicHistory.backView() stateParams 변경 후 돌아가기 (Going back after changing stateParams of $ionicHistory.backView())







코멘트