網站首頁 編程語言 正文
html部分
?
1111這是測試的文本內容,沒有實際意義。
2222這是測試的文本內容,沒有實際意義。
css部分 第一個是超出出現 ... 第二個是不超出的
注意:超出出現... 需要用這種寫法
.text{
display: inline-block;
width: 100px;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp:1;
}
.text2{
width: 500px;
}
自定義指令
Vue.directive('showByContent', {
inserted(el, binding) {
// 實際高度 小于 1.5倍顯示高度 (1.5倍為邊界值的兼容)
if(el.scrollHeight < el.offsetHeight * 1.5){
// 隱藏 tooltip
let openDelay = el.__vue__ && el.__vue__.openDelay || 10
el.addEventListener('mouseenter', () => {
let ariaDescribedby = el.attributes['aria-describedby'].value
// 鼠標移入之后延遲10ms把顯示出來的tooltip的dom 給隱藏起來,tooltip的節點id為當前dom的aria-describedby值 通過這個關系查找的指定的框
setTimeout(res=>{
if(!document.getElementById(ariaDescribedby)){ return }
document.getElementById(ariaDescribedby).style.display = 'none'
},openDelay + 10)
})
}
},
})
有其他更好的方法,歡迎分享。
有錯誤歡迎指正!
原文鏈接:https://blog.csdn.net/banglei123/article/details/122699830
相關推薦
- 2022-12-23 C++中關于constexpr函數使用及說明_C 語言
- 2023-02-15 nginx如何配置x-forwarded-for頭部_nginx
- 2023-01-15 GoLang內存泄漏原因排查詳解_Golang
- 2022-07-04 C#?WinForm制作登錄界面的實現步驟_C#教程
- 2023-04-19 微信小程序授權登錄三種實現方式
- 2022-12-13 torch.optim優化算法理解之optim.Adam()解讀_python
- 2022-11-03 tomcat?集群監控與彈性伸縮詳解_Tomcat
- 2022-05-04 C#設計模式之單例模式_C#教程
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支