参考:https://blog.csdn.net/lunhui1994_/article/details/81120579

效果:

html:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>test</title>
<link rel="stylesheet" href="css/amazeui.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<style>
.table-items {
table-layout: fixed;//td的宽度固定,不随内容变化
} .table-items>tbody>tr>td {//文字超出显示省略号
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="am-cf">
<table class="am-table am-table-hover table-items">
<thead>
<tr>
<th style="width:25%">序号</th>
<th style="width:40%">姓</th>
<th style="width:35%">名</th>
</tr>
</thead>
<tbody id="table-body"></tbody>
</table>
</div>
<script type="text/javascript">
var dataList = [{
id: 1,
first_name: 'honorificabilitudinitatibushonorificabilitudinitatibus',
second_name: 'antidisestablishmentarianismantidisestablishmentarianism'
}, {
id: 2,
first_name: 'floccinaucinihilipipificationfloccinaucinihilipipification',
second_name: 'supercalifragilisticexpiadocioussupercalifragilisticexpiadocious'
}, {
id: 3,
first_name: 'hepaticocholecystostcholecystntenterostomyhepaticocholecystostcholecystntenterostomy',
second_name: 'pneumonoultramicyoscpicailicovolcanoconiosispneumonoultramicyoscpicailicovolcanoconiosis '
}];
$(function() {
var str = '';
for (var i = 0; i < dataList.length; i++) {
str = "<tr><td title=" + dataList[i].id + ">" + dataList[i].id + "</td>" +
"<td title=" + dataList[i].first_name + ">" + dataList[i].first_name + "</td>" +
"<td title=" + dataList[i].second_name + ">" + dataList[i].second_name + "</td>" +
"</tr>";
$('#table-body').append(str);
}
})
</script>
</body>
</html>

td里的title属性是鼠标悬停上方时显示内容。

table 单列宽度设置的更多相关文章

  1. table 的宽度设置无效

    1.在table 标签添加样式 table-layout: fixed; 必须设置width的值:<table style="table-layout: fixed"> ...

  2. table表格宽带研究(附带:table表格为什么设置td宽度无效)

    情况1:下面代码定义了表格宽带为为600px,未设置td宽带,3个td内容为1,2,3,可以看到3个内容平分table的宽度. 也就是每个td都是200px(请注意:如果用chrome调试宽度,会有一 ...

  3. 表格Table宽度设置无效的解决方法

    表格Table宽度设置无效的解决方法 bootstrap中使用table时发现不管用width赋值方式都无法改变table>td的宽度 解决方法: 设置table:table-layout:fi ...

  4. table表格宽度固定,同时td内容过长也不会被撑开

    table表格宽度固定,同时td内容过长也不会被撑开,设置如下css: table{table-layout:fixed;word-break:break-all;}

  5. css中关于table的相关设置

    一.设置好看的单边框表格 1.一种实现方式 分别给table标签和td标签设置不在同一方向的border属性,如下table设置‘左上’边框,td设置‘右下’边框.其他设置方式同样可以实现. tabl ...

  6. Table的一些设置(自适应以及溢出)

    table的两个属性 单行溢出点点显示 表格的宽度设置 双栏自适应连续连续英文符换行 1.table重置的两个属性: ①border-collapse: collapse;      /* 为表格设置 ...

  7. TD中INPUT的宽度设置

    最近在用C#做Web程序时,碰到一个问题: 将TextBox的asp控件放在Table中的TD里面时,不设置宽度,自动会将TD撑的很大. 查看运行后页面的源代码发现,其实TextBox控件最终在客户端 ...

  8. 如何固定table表格宽度,样式不受容器影响

    之前有篇关于LODOP打印超文本表格,两个样式相同的表格,出现错位的情况.该博文地址:LODOP打印表格错位的几种情况该文试验了两种现象,第一种浏览器页面显示错位,打印预览也错位,第二种浏览器页面表格 ...

  9. LODOP打印table表格宽度固定-超宽隐藏

    之前有博文介绍关于超出div隐藏内容的:LODOP打印超过后隐藏内容样式里面提到了overflow:hidden;控制超出后隐藏,但是前面那篇用的是div,如果是在table中,由于table默认的t ...

随机推荐

  1. 解决spring boot中普通类中使用service为null 的方法

    我使用的是springboot+mybatisplus +mysql1.创建一个SpringUtil工具类 import org.springframework.beans.BeansExceptio ...

  2. python 获取手机设备号

    上代码 ##获取设备多台设备号列表 def get_deviceid(): str_init=' ' all_info= os.popen('adb devices').readlines() pri ...

  3. 树莓派安装raspbian

    需要准备 Win32DiskImager-v0.6 2016-09-23-raspbian-jessie.img 右键管理员打开Win32DiskImager 选择上面的img文件,选择存储卡盘符,点 ...

  4. Bootstrap-table 使用总结 转载https://www.cnblogs.com/laowangc/p/8875526.html

    一.什么是Bootstrap-table? 在业务系统开发中,对表格记录的查询.分页.排序等处理是非常常见的,在Web开发中,可以采用很多功能强大的插件来满足要求,且能极大的提高开发效率,本随笔介绍这 ...

  5. jmeter 读写excel插件编写教程系列(1) -开篇

    不知道为什么,jmeter 竟然不提供 读写excel 的Sampler! 但是在我们自动化接口测试过程中,参数化.保存测试数据,用excel 是比较好的解决方案! 接下来一段儿时间,大虫会抽出一些时 ...

  6. PHP之数据连接方法(二)

    首先API接口,无非就是通过该程序去处理数据的数据,及判断数据的准确性. 因此我们需要一个DBTool的操作方法. DBTool地址:https://github.com/gfarmhuang/DBT ...

  7. 第一个gulp 项目

    1.  全局安装 npm install --global gulp 2.新建一个project文件夹,并在该目录下执行 npm init 命令: 3.把项目的基本文件夹搭好 4.在项目中局部安装 n ...

  8. hadoop.io.native.NativeID$Windows.access0 报错问题解决

    系统:win10 hadoop-2.6.0版本 java:1.8 版本32位   wordcount在本地运行时报错: Exception in thread "main" jav ...

  9. mysql-5.5.17-win64 安装方法

    双击mysql-5.5.17-win64.msi,即开始安装,出现如下界面 2 点击next,出现如下界面,默认为Typical,改选为Custom,单击Next 3 选择MySQL Server后, ...

  10. JAVA去除抖音视频的水印源码!!!

    @PostMapping("geturl") public DataResponse decodeDouiyin(@RequestBody DouyinRequest req ) ...