Javascript 如何将大文本包装在表格中,并在鼠标悬停时显示为弹出框?
这可以只用HTML和CSS来完成吗? 下面是我试过的代码。问题在于鼠标悬停时,它会将其显示在同一单元格中,并更改表格的宽度。有没有办法将文本显示为弹出框Javascript 如何将大文本包装在表格中,并在鼠标悬停时显示为弹出框?,javascript,jquery,html,css,angularjs,Javascript,Jquery,Html,Css,Angularjs,这可以只用HTML和CSS来完成吗? 下面是我试过的代码。问题在于鼠标悬停时,它会将其显示在同一单元格中,并更改表格的宽度。有没有办法将文本显示为弹出框 表td.text{ 最大宽度:10px; } 表td.text span{ 空白:nowrap; 溢出:隐藏; 文本溢出:省略号; 显示:内联块; 最大宽度:100%; } 表td.text跨度:悬停{ 背景色:#BDE5F8; 溢出:可见; 空白:正常; 高度:自动; /*刚刚加了这一行*/ } 专栏1 专栏2 第3栏 Lorem Ips
表td.text{
最大宽度:10px;
}
表td.text span{
空白:nowrap;
溢出:隐藏;
文本溢出:省略号;
显示:内联块;
最大宽度:100%;
}
表td.text跨度:悬停{
背景色:#BDE5F8;
溢出:可见;
空白:正常;
高度:自动;
/*刚刚加了这一行*/
}
专栏1
专栏2
第3栏
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
您可以使用位置:绝对
使文本在悬停时脱离流
表td.text{
最大宽度:10px;
}
表td.text span{
空白:nowrap;
溢出:隐藏;
文本溢出:省略号;
显示:内联块;
最大宽度:100%;
}
表td.text:悬停范围:非(.empty){
背景色:#BDE5F8;
溢出:可见;
空白:正常;
高度:自动;
/*刚刚加了这一行*/
位置:绝对位置;
}
专栏1
专栏2
第3栏
专栏4
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
您可以使用位置:绝对
使文本在悬停时脱离流
表td.text{
最大宽度:10px;
}
表td.text span{
空白:nowrap;
溢出:隐藏;
文本溢出:省略号;
显示:内联块;
最大宽度:100%;
}
表td.text:悬停范围:非(.empty){
背景色:#BDE5F8;
溢出:可见;
空白:正常;
高度:自动;
/*刚刚加了这一行*/
位置:绝对位置;
}
专栏1
专栏2
第3栏
专栏4
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
试试这个
。展开{
最大宽度:50px;
空白:nowrap;
溢出:隐藏;
}
.展开:悬停{
最大宽度:初始宽度;
}
Lorem
Ipsum
1.
Lorem ipsum dolor sit amet,是一位杰出的献身者。
试试这个
。展开{
最大宽度:50px;
空白:nowrap;
溢出:隐藏;
}
.展开:悬停{
最大宽度:初始宽度;
}
Lorem
Ipsum
1.
Lorem ipsum dolor sit amet,是一位杰出的献身者。
您可以使用title属性,而不使用悬停css。我在这里复制代码只是为了向您展示一种方法,但您应该使用javascript将文本数据操纵到title属性中,而不是在这里使用复制
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
table td.text {
max-width: 10px;
}
table td.text span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
max-width: 100%;
}
</style>
</head>
<body>
<table>
<thead>
<tr class="text-center">
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
</tr>
</thead>
<tr>
<td class="text" title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."><span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</span>
</td>
<td class="text" title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."><span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</span>
</td>
<td class="text" title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."><span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</span>
</td>
</tr>
</table>
</body>
</html>
表td.text{
最大宽度:10px;
}
表td.text span{
空白:nowrap;
溢出:隐藏;
文本溢出:省略号;
显示:内联块;
最大宽度:100%;
}
专栏1
专栏2
第3栏
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是业界标准的虚拟文本,当时一家不知名的印刷商将一个印刷机上的字体拼凑到了ma