表格单元格的滚动条 [英] scroll bar for a table cell

查看:25
本文介绍了表格单元格的滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法向td"标签添加滚动条?我在td"标签中有一个动态内容.我希望 'td' 为固定大小,如果内容变得大于 'td' 大小,我希望滚动条仅出现在该特定单元格上.有没有办法做到这一点?

解决方案

是的,你可以这样做.

最简单的方法是在单元格内放置一个 div 填充它并设置它的 overflow 样式属性.

CSS:

div.scrollable {宽度:100%;高度:100%;边距:0;填充:0;溢出:自动;}

HTML:

如果单元格太大,一些带有滚动条的内容</div></td>

如果您希望滚动条始终可见,即使内容未被裁剪,请将 CSS 中的 auto 替换为 scroll.

演示

Is there a way to add a scroll bar to a 'td' tag? I have a dynamic content inside a 'td' tag. I want the 'td' to be of fixed size and if the content becomes larger than the 'td' size, I want a scroll bar to appear only on that particular cell. Is there a way to achieve this?

解决方案

Yes you can do that.

The easiest way is to put inside your cell a div filling it and set its overflow style property.

CSS :

div.scrollable {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: auto;
}

HTML :

<td><div class=scrollable>
    Some content with a scrollbar if it's too big for the cell
</div></td>

If you want the scrollbar to be always visible, even when the content isn't cropped, replace auto with scroll in the CSS.

Demonstration

这篇关于表格单元格的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆