第一种实现方式:鼠标移动到标题上面,弹出悬浮窗,用函数来实现。
<div class='requirement_css' onmouseover="overShow(this,event)" onmouseout="outHide()">
<span class="m-l" ng-bind="item.name |cut:true:60:'...'">Task title</span>
</div>
<script>
function overShow(obj, e) {
var showDiv = document.getElementById('showDiv');
var theEvent = e ? e : window.event;
showDiv.style.left = theEvent.clientX + document.body.scrollLeft - 5 + "px";
showDiv.style.top = theEvent.clientY + document.body.scrollTop - 50 + "px";
showDiv.style.display = 'block';
showDiv.innerHTML = obj.innerHTML;
}
function outHide() {
var showDiv = document.getElementById('showDiv');
showDiv.style.display = 'none';
showDiv.innerHTML = '';
}
</script>
<div id="showDiv"
style=" position:absolute;width: auto;height:40px;font-size:16px;background-color:#f1f4f5;display: none "></div>
</accordion-heading>
另一种方法:在标题下方显示完整标题,使用AngularJs的自带的指令:ng-mouseenter和ng-mouseleave,注意,ng-mouseenter和ng-mouseleave要写在需要控制的标签内。
<div class='requirement_css' >
<span ng-mouseenter="show=true" ng-mouseleave="show=false" class="m-l" ng-bind="item.name |cut:true:60:'...'">Task title</span>
</div>
<div ng-show="show" style="padding:10px 0;font-size: 14px;line-height: 100% ; background-color:#f3f3f3; ">
<a>{{ item.name }}</a>
</div>
定义的CSS样式
.requirement_css {
width: 300px;
height: 20px;
font-size: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
<div class='requirement_css' onmouseover="overShow(this,event)" onmouseout="outHide()">
<span class="m-l" ng-bind="item.name |cut:true:60:'...'">Task title</span>
</div>
<script>
function overShow(obj, e) {
var showDiv = document.getElementById('showDiv');
var theEvent = e ? e : window.event;
showDiv.style.left = theEvent.clientX + document.body.scrollLeft - 5 + "px";
showDiv.style.top = theEvent.clientY + document.body.scrollTop - 50 + "px";
showDiv.style.display = 'block';
showDiv.innerHTML = obj.innerHTML;
}
function outHide() {
var showDiv = document.getElementById('showDiv');
showDiv.style.display = 'none';
showDiv.innerHTML = '';
}
</script>
<div id="showDiv"
style=" position:absolute;width: auto;height:40px;font-size:16px;background-color:#f1f4f5;display: none "></div>
</accordion-heading>
另一种方法:在标题下方显示完整标题,使用AngularJs的自带的指令:ng-mouseenter和ng-mouseleave,注意,ng-mouseenter和ng-mouseleave要写在需要控制的标签内。
<div class='requirement_css' >
<span ng-mouseenter="show=true" ng-mouseleave="show=false" class="m-l" ng-bind="item.name |cut:true:60:'...'">Task title</span>
</div>
<div ng-show="show" style="padding:10px 0;font-size: 14px;line-height: 100% ; background-color:#f3f3f3; ">
<a>{{ item.name }}</a>
</div>
定义的CSS样式
.requirement_css {
width: 300px;
height: 20px;
font-size: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}