英文:
How do I wrap text in ionic 7 labels or inputs as pervious answers no longer work
问题
以下是您要翻译的内容:
在以前的ionic版本中,您可以使用<ion-label class="ion-text-wrap"或
.item.sc-ion-label-md-h,.item .sc-ion-label-md-h {
white-space: normal !important;
}
.item.sc-ion-label-ios-h,.item .sc-ion-label-ios-h {
white-space: normal !important;
}
以下是ionic文档中的一些示例
html
<ion-input class="custom" label="Long Long Long Text Here"></ion-input>
scss
ion-input.custom {
--background: #373737;
--color: #fff;
--padding-end: 10px;
--padding-start: 10px;
--placeholder-color: #ddd;
--placeholder-opacity: 0.8;
}
我尝试添加
--white-space: normal !important;
ionic似乎正在摆脱
<ion-label>Label Here</ion-label>
任何帮助将不胜感激。
英文:
In previous versions of ionic you could use <ion-label class="ion-text-wrap"
or
.item.sc-ion-label-md-h, .item .sc-ion-label-md-h{
white-space: normal !important;
}
.item.sc-ion-label-ios-h, .item .sc-ion-label-ios-h{
white-space: normal !important;
}
Here are some examples of what the ionic docs say
html
<ion-input class="custom" label="Long Long Long Text Here"></ion-input>
scss
ion-input.custom {
--background: #373737;
--color: #fff;
--padding-end: 10px;
--padding-start: 10px;
--placeholder-color: #ddd;
--placeholder-opacity: 0.8;
}
I tried adding
--white-space: normal !important;
ionic seems to be moving away from
<ion-label>Label Here</ion-label>
Any help would be appreciated.
答案1
得分: 1
这是我遇到的同样问题,以下是我想出来的解决方法:
- 为了保持一致性,我将内置的
ion-text-wrap类添加到我想要包装标签的元素上,例如ion-input或ion-textarea。 - 然后我在
global.scss中添加了以下规则:
[label].ion-text-wrap .label-text-wrapper > .label-text {
white-space: normal;
}
这对我有帮助,希望对你也有帮助。
英文:
I faced the same issue, and here is what I came up with:
- For consistency, I added the built-in
ion-text-wrapclass to the elements whose label I want to be wrapped, e.g.,ion-inputorion-textarea. - And I added the following rule to
global.scss:
[label].ion-text-wrap .label-text-wrapper > .label-text {
white-space: normal;
}
It helped me, and I hope it will help you too.
答案2
得分: 0
这是ionic 7中的一个错误,在任何地方<ion-label>被替换为labelPlacement=""。您不再能够换行文本。我将把我的项目转回ionic 6。
英文:
This is a bug in ionic 7 any where <ion-label> has been replaced labelPlacement="". you no longer have the ability to wrap text. I will convert my project back to ionic 6
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论