简体   繁体   English

引导表响应无法正常工作-宽度问题

[英]bootstrap table-responsive doesn't work well - width issue

I have problem with names, that are too long to fit in column, it looks like this: 我的名称有问题,名称太长而无法容纳在列中,它看起来像这样:

http://i.stack.imgur.com/1xwZz.png http://i.stack.imgur.com/1xwZz.png

I've tried to specify exactly max-width of element but it doesn't work well. 我试图确切指定元素的最大宽度,但效果不佳。

I would like to show only beginning of name, and whole name in title element, 我只想在title元素中显示名称的开头和全名,

My code for now looks like this: 我的代码现在看起来像这样:

<div class="table-responsive">
<table class="table table-hover table-condensed table-striped">
    <thead>
        <tr>
            <th>&nbsp;</th>
            <th>name</th>
            <th>size</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody id="List">
        <tr class="line1">
            <td class="">
                <img src="gfx/icons/image.png"></td>
            <td class="fileName">
                <a href="#">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg</a>
            </td>
            <td class="fileSize">41.2 kB</td>
            <td class="delete">
                <a class="btn btn-danger btn-xs" href="#"><span class="glyphicon glyphicon-floppy-remove"></span></a>
            </td>
        </tr>
    </tbody>
</table>

As a comment stated this is not the solution you asked for but an alternative, since cutting the name of the file down requires either JavaScript or some server side language, if you use one. 就像评论中指出的那样,这不是您要的解决方案,而是替代方案,因为如果您使用一种语言,则缩减文件名需要JavaScript或某种服务器端语言。 If you specify the preferred way to solve this I can give a more in-depth solution. 如果您指定解决此问题的首选方法,我可以提供更深入的解决方案。

The table seems to work as intended and although it is bad practice to have such long filenames, I understand that if you allow users to upload files on a website, you have no control over the filenames. 该表似乎可以按预期工作,尽管有这么长的文件名是一种不好的做法,但我理解如果您允许用户在网站上上传文件,则无法控制文件名。 So, the solution I would use in your case is some custom CSS: 因此,我将在您的情况下使用的解决方案是一些自定义CSS:

.filename a {
  word-break: break-all;
}

This will make the filename split into two lines when needed. 这将在需要时将文件名分成两行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM