這篇文章將為大家詳細(xì)講解有關(guān)Layer.js怎么實(shí)現(xiàn)表格溢出內(nèi)容省略號顯示懸停顯示全部的方法,小編覺得挺實(shí)用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
成都網(wǎng)絡(luò)公司-成都網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站十載經(jīng)驗(yàn)成就非凡,專業(yè)從事成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作,成都網(wǎng)頁設(shè)計(jì),成都網(wǎng)頁制作,軟文推廣,廣告投放等。十載來已成功提供全面的成都網(wǎng)站建設(shè)方案,打造行業(yè)特色的成都網(wǎng)站建設(shè)案例,建站熱線:18980820575,我們期待您的來電!
Index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表格內(nèi)容溢出省略號顯示</title> <style type="text/css"> .contain { font-family: ‘ Microsoft YaHei '; margin: 15px auto; width: 900px; } table { border: 1px solid #e3e6e8; border-collapse: collapse; display: table; table-layout: fixed; text-align: center; width: 100%; } th, td { border: 1px solid #e3e6e8; height: 38px; line-height: 38px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } th { background-color: #189AD6; color: #fff; } .layui-layer { word-break: break-all; word-wrap: break-word; } </style> <!--relate to this page javascript--> <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script> <script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script> </head> <body> <div class="contain"> <table> <thead> <th>貨幣</th> <th>本周收盤</th> <th>上周收盤</th> <th>漲跌</th> <th>幅度</th> </thead> <tbody> <tr> <td>EURGBP“EUR/GBP settled above 0.90 on Friday as the bounce in EUR/USD helped the lift the pair further into the 0.90 territory”.</td> <td>0.86333333333393222222</td> <td>0.88945555555555555553</td> <td>-203333333333333333111</td> <td>-2.3166%</td> </tr> <tr> <td>EURGBP</td> <td>0.8693</td> <td>0.8894</td> <td>-201</td> <td>-2.31%</td> </tr> <tr> <td>EURGBP</td> <td>0.8693</td> <td>0.8894</td> <td>-201</td> <td>-2.31%</td> </tr> </tbody> </table> </div> <script type="text/javascript"> $(function() { $("td").on("mouseenter", function() { //js主要利用offsetWidth和scrollWidth判斷是否溢出。 //在這里scrollWidth是包含內(nèi)容的完全高度,offsetWidth是當(dāng)前表格單元格的寬度。 if (this.offsetWidth < this.scrollWidth) { var that = this; var text = $(this).text(); window.layer.tips(text, that, { tips: 1, time: 2000 }); } }); }) </script> </body> </html>
效果如圖:
關(guān)于“Layer.js怎么實(shí)現(xiàn)表格溢出內(nèi)容省略號顯示懸停顯示全部的方法”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
網(wǎng)頁名稱:Layer.js怎么實(shí)現(xiàn)表格溢出內(nèi)容省略號顯示懸停顯示全部的方法
文章轉(zhuǎn)載:http://bm7419.com/article44/pscohe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站導(dǎo)航、網(wǎng)站建設(shè)、小程序開發(fā)、網(wǎng)站維護(hù)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)