table 单列宽度设置
参考: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 单列宽度设置的更多相关文章
- table 的宽度设置无效
1.在table 标签添加样式 table-layout: fixed; 必须设置width的值:<table style="table-layout: fixed"> ...
- table表格宽带研究(附带:table表格为什么设置td宽度无效)
情况1:下面代码定义了表格宽带为为600px,未设置td宽带,3个td内容为1,2,3,可以看到3个内容平分table的宽度. 也就是每个td都是200px(请注意:如果用chrome调试宽度,会有一 ...
- 表格Table宽度设置无效的解决方法
表格Table宽度设置无效的解决方法 bootstrap中使用table时发现不管用width赋值方式都无法改变table>td的宽度 解决方法: 设置table:table-layout:fi ...
- table表格宽度固定,同时td内容过长也不会被撑开
table表格宽度固定,同时td内容过长也不会被撑开,设置如下css: table{table-layout:fixed;word-break:break-all;}
- css中关于table的相关设置
一.设置好看的单边框表格 1.一种实现方式 分别给table标签和td标签设置不在同一方向的border属性,如下table设置‘左上’边框,td设置‘右下’边框.其他设置方式同样可以实现. tabl ...
- Table的一些设置(自适应以及溢出)
table的两个属性 单行溢出点点显示 表格的宽度设置 双栏自适应连续连续英文符换行 1.table重置的两个属性: ①border-collapse: collapse; /* 为表格设置 ...
- TD中INPUT的宽度设置
最近在用C#做Web程序时,碰到一个问题: 将TextBox的asp控件放在Table中的TD里面时,不设置宽度,自动会将TD撑的很大. 查看运行后页面的源代码发现,其实TextBox控件最终在客户端 ...
- 如何固定table表格宽度,样式不受容器影响
之前有篇关于LODOP打印超文本表格,两个样式相同的表格,出现错位的情况.该博文地址:LODOP打印表格错位的几种情况该文试验了两种现象,第一种浏览器页面显示错位,打印预览也错位,第二种浏览器页面表格 ...
- LODOP打印table表格宽度固定-超宽隐藏
之前有博文介绍关于超出div隐藏内容的:LODOP打印超过后隐藏内容样式里面提到了overflow:hidden;控制超出后隐藏,但是前面那篇用的是div,如果是在table中,由于table默认的t ...
随机推荐
- Appium 工作原理
Appium - automation for mobile apps 一.Appium架构介绍 官网:www.appium.io 由SauceLab公司主持.并在Google的GATC2013会 ...
- JS基础复习
js基础语法 Netcape js基础语法规范(ECMAScript1,2,3,3.1,5(IE9),6 ES ES6=es2015) DOM BOM ...
- jQuery全部选择器总结(转载)
jQuery选择器总结 不知道为什么博客园不能转载文章?如果知道如何转载的朋友可以评论告诉我,我只能ctrl+C/V下来,转载自: http://www.cnblogs.com/mcgrady/arc ...
- testNG官方文档翻译-2 注解
这里是一份TestNG中的可用注解及其属性的概述. 一.用于一个TestNG类的信息配置的注解: @BeforeSuite:被BeforeSuite注解的方法将在其所在suite中的所有test运行之 ...
- 调用API接口,查询手机号码归属地(2)
使用pymysql pip install pymysql 创建mysql测试表 CREATE TABLE `userinfo` ( `id` int(20) NOT NULL AUTO_INCREM ...
- java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened because it does not exist
今天启动web 项目出现错误提示: java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened becau ...
- 2-数据分析-matplotlib-1-概述
1.matplotlib: 最流行的Python底层绘图库,主要做数据可视化图表,名字取材于MATLAB,模仿MATLAB构建. 2.学习matplotlib的意义: (1)能将数据进行可视化,更直观 ...
- 基于nginx+tomcat部署商城系统并连接数据库
需三台服务器nginx 192.168.200.111tomcat 192.168.200.112tomcat 192.168.200.113 192.168.200.111[root@localho ...
- VS2017 打包(详细)
1.安装打包插件:Microsoft Visual Studio 2017安装程序项目 2.联机查找下面的组件,然后安装,重启VS,进行插件安装 3.新建安装项目,另外,有些人可能会想这么多安装类 ...
- main中的argc,argv
那么我们运行程序时,传入的参数,就是这个argc的值:从截图中,我们很清楚的可以看出,argc是传入参数的个数,”传入的参数“加上可执行文件的文件名: