Table相关整理及Javascript操作table,tr,td_HTML/Xhtml_网页制作

WBOY
Release: 2016-05-16 16:40:29
Original
1255 people have browsed it

效果良好的表属性设置:

复制代码
代码如下:

style='border-collapse:collapse;table-layout: fixed'>

很多人都有这种经历:当某个td中没有内容或者没有可见元素时,td的border也会消失。解决方案就是给table添加样式border-collapse:collapse
一般的文字截断(适用于内联与块):

复制代码
代码如下:

.text-overflow{
display:block;/*内联对象需加*/
width:31em;
word-break:keep-all;/* 不换行 */
white-space:nowrap;/* 不换行 */
overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/
}

对于表格的话,定义有一点不一样:

复制代码
代码如下:

table{
width:30em;
table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */
}
td{
width:100%;
word-break:keep-all;/* 不换行 */
white-space:nowrap;/* 不换行 */
overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/
}

Javascript操作table,tr,td

复制代码
代码如下:

table.moveRow(m,n)//交换表的行(IE) m和n之间的行依次移动
table.deleteRow(index)//行删除
table.insertRow(index)//在index位置插入行,并返回该TR
tr.insertCell(index)//插入单元格,并返回该TD
tr.deleteCell(index)
tr.rowIndex//返回tr在表中的位置
td.cellIndex //返回td在tr中的位置
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!