【发布时间】:2018-02-16 14:46:00
【问题描述】:
我正在开发一个 Ionic 应用程序,但我的标题组件有问题。它的元素以小屏幕尺寸包裹,我不希望它们这样做。
这是目标:
这是现在发生的事情:
我知道我可以为标题设置固定宽度,但我不想这样做。我也不想用 JavaScript 来计算宽度。
这是标题组件的 HTML/Angular/Ionic 代码:
<h1 *ngIf="backButton; else titleBackButton">{{ title }}</h1> <!-- show if backButton != true -->
<ng-template #titleBackButton> <!-- show if backButton == true -->
<button ion-button round class="button-back">
<ion-icon name="arrow-back"></ion-icon>
</button>
<h1 class="floated-title">{{ title }}</h1> <!-- this has been floated to the right -->
</ng-template>
这是我的 CSS 样式:
.button-back {
margin: 17px 0 0 10px;
}
.floated-title {
float: right;
}
【问题讨论】:
-
要么在移动设备上缩小字体大小......要么让单词本身中断,要么在 HTML 代码中使用软连字符(更多控制),要么 CSS 属性
overflow-wrap和/或hyphens...? (这似乎是你在其他项目中已经以某种方式实现的目标,所以......)
标签: html css angular ionic-framework