td标签外的单词

时间:2019-02-07 10:19:55

标签: html css

之间没有空格的单词用完了标签。我当时使用断字功能,但对我有用。我该怎么做,使单词不会超出表格框。单词之间没有空格的单词将用完标签。我当时使用断字功能,但对我有用。我该怎么做才能使单词不会超出表格框

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Sales Report</title>
    <style type="text/css">
        @page {
            size: A4;
            margin: 1cm;
        }
        .table {
            width: 100%;
            max-width: 100%;
            margin-bottom: 5px;
            background-color: #fff;
            border: 1px solid #000;
        }
        .table th,
        .table td {
            padding: 5px;
            vertical-align: top;
            border: 1px solid #000;
            text-align: center;
            word-wrap:break-word; /* this is not working */ 
        }
        .table thead th {
            vertical-align: bottom;
            border-bottom: 2px solid #000;
        }
        .table tbody + tbody {
            border-top: 2px solid #000;
        }
        .table .table {
            background-color: #fff;
        }
        .list-group {
            display: block;
            width: 100%;
            list-style: none;
            margin-top: 15px;
            margin-bottom: 15px;
        }
        .list-group p {
            width: 100%;
            height: 30px;
            line-height: 20px;
            list-style: none;
            font-size: 3.64em;
        }
    </style>
</head>
<body>

<div class="container">
    <div class="card">
        <div class="card-header">
            <h3>Sales Report - {% now "jS F Y H:i" %}</h3>
        </div>

        <div class="list-group">
            <p>Name: {{ request.user.first_name }} {{ request.user.last_name }}</p>
        </div>

        <table class="table">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Company Name</th>
                    <th>Company Email</th>
                    <th>Count Of Total Users</th>
                    <th>Created Date</th>
                    <th>Current Monthly Payment</th>
                    <th>Is TABopts Customer</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                {% if companies %}
                {% for company in companies %}
                        <tr>
                            <td>{{ forloop.counter }}</td>                            <td>{{ company.company_name }}</td>
                            <td>{{ company.company_email }}afsdasdfasdfasdf</td>
                            <td>{{ company.number_of_company_users }}</td>
                            <td>{{ company.company_created |date:"M d, Y" }}</td>
                            <td>{{ company.company_monthly_payment }}</td>
                            <td>{{ company.company_tab_opts }}</td>
                            <td>{{ company.company_status }}</td>
                        </tr>
                 {% endfor %}
                 {% endif %}
            </tbody>
        </table>
    </div>
</div>

</body>
</html>

3 个答案:

答案 0 :(得分:0)

尝试使用此{{company.company_email asdsdadsafaf}}

答案 1 :(得分:0)

您可以将word-break: break-all;用于td来解决您的问题

table{
 width: 100px;
}

td{
word-break: break-all;
}
<table>
<tr>
<td>sfdghjkljjhgfdsadfghjkljhgfdsfghjkljkhgfdsdfghjklhgfdsfgfhjhkjkhgf</td>
</tr>
</table>

答案 2 :(得分:0)

使用以下CSS防止单词溢出。

td{
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}