table内文字一行内显示
2016-03-10 17:05
435 查看
/*样式*/
table{display:fixed;width:100%;}
注意table要有宽度属性
针对要一行显示的文字添加样式类inlinetxt
inlinetxt{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{padding:0;margin:0;border:0;}
table {border-collapse:collapse;border-spacing:0;}
.content{width:1000px;margin:0 auto;}
.content table,.content table td{border:1px solid #ddd;}
.content table{table-layout:fixed;width:100%;}
.inlinetxt{overflow:hidden;text-overflow:ellipsis;white-space: nowrap;}
</style>
</head>
<body>
<div class="content">
<table>
<tbody>
<tr>
<td class="inlinetxt">测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
table{display:fixed;width:100%;}
注意table要有宽度属性
针对要一行显示的文字添加样式类inlinetxt
inlinetxt{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{padding:0;margin:0;border:0;}
table {border-collapse:collapse;border-spacing:0;}
.content{width:1000px;margin:0 auto;}
.content table,.content table td{border:1px solid #ddd;}
.content table{table-layout:fixed;width:100%;}
.inlinetxt{overflow:hidden;text-overflow:ellipsis;white-space: nowrap;}
</style>
</head>
<body>
<div class="content">
<table>
<tbody>
<tr>
<td class="inlinetxt">测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
<td>测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
相关文章推荐
- Android Native 绘图方法
- C#中struct和class的区别详解
- VBS ArrayList Class vbs中的数组类
- 大家看了就明白了css样式中类class与标识id选择符的区别小结
- 深入了解PHP类Class的概念
- jquery 表单验证之通过 class验证表单不为空
- setAttribute 与 class冲突解决
- JavaScript中的类(Class)详细介绍
- javascript面向对象包装类Class封装类库剖析
- 详解js中class的多种函数封装方法
- jQuery使用hide方法隐藏指定元素class样式用法实例
- jQuery给多个不同元素添加class样式的方法
- jQuery点击改变class并toggle及toggleClass()方法定义用法
- jquery采用oop模式class类的使用示例
- JavaScript更改class和id的方法
- 一篇入门的php Class 文章
- 深入C++中struct与class的区别分析
- js中设置元素class的三种方法小结
- JavaScript操作class和style样式代码详解
- c++中typename和class的区别介绍