如何在角材料设计的工具提示中添加换行符 [英] How to add line breaks within tooltip in angular material design
问题描述
如何在工具提示中添加换行符 我已经实现了工具提示,但无法在工具提示中添加多行或换行符.下面是我的代码
How to add line break in tooltip I have implemented the Tooltip but i am not able to add multi line or line breaks in tooltip.Below is my code
http://codepen.io/apps4any/pen/RWQLyr
HTML
<div ng-controller="AppCtrl" ng-cloak="" class="tooltipdemoBasicUsage" ng-app="MyApp">
<md-content layout-padding="">
<md-button class="md-fab md-fab-top-right right" aria-label="Photos">
<md-icon md-svg-src="img/icons/ic_photo_24px.svg" style="width: 24px; height: 24px;"></md-icon>
<md-tooltip>
List1<br>
List2<br>
List3<br>
List4
</md-tooltip>
</md-button>
<div style="margin-top: 150px;">
</div>
</md-content>
</div>
CSS:
.tooltipdemoBasicUsage md-toolbar .md-toolbar-tools .md-button, .tooltipdemoBasicUsage md-toolbar .md-toolbar-tools .md-button:hover {
box-shadow: none;
border: none;
transform: none;
-webkit-transform: none; }
.tooltipdemoBasicUsage .left {
top: 70px !important;
left: 56px !important; }
.tooltipdemoBasicUsage .right {
top: 70px !important;
right: 56px !important; }
JS
angular.module('MyApp')
.controller('AppCtrl', function($scope) {
$scope.demo = {};
});
推荐答案
添加这种CSS似乎可以解决您的问题(对于<br>
s):
Adding this CSS seems to work in your case (with the <br>
s):
md-tooltip .md-content {
height: auto;
}
我不确定为什么Angular-Material将高度硬编码为22px.您需要检查此更改是否破坏了其他工具提示.
I'm not sure why Angular-Material hard-coded the height to 22px. You'll need to check whether this change breaks other tooltips.
或者您可以仅通过给它一个类,例如将其专门应用于此用例. tt-multiline
,因此您可以在CSS中定位它:
Or you can apply it specifically to this use case only by giving it a class, e.g. tt-multiline
, so you can target it in CSS:
md-tooltip.tt-multiline .md-content {
height: auto;
}
从Angular-Material 1.1开始,某些类名称已更改为以下划线开头.
Starting from Angular-Material 1.1, some class names have changed to start with a underscore.
在这种情况下,请使用
md-tooltip ._md-content {
height: auto;
}
以及针对特定班级
md-tooltip.tt-multiline ._md-content {
height: auto;
}
这篇关于如何在角材料设计的工具提示中添加换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!