【发布时间】:2020-01-15 20:39:06
【问题描述】:
我正在开发一个日历,我需要在一周中的某些日子(表格的单元格)编写事件(文本)。 问题是当单元格中的文本非常大并且单元格相应增加时。
我需要固定大小的单元格和固定大小的事件(带文本的 div)。 代码:
table {
font-size: 0.875rem;
font-weight: 400;
line-height: 1.5;
direction: ltr;
text-align: center !important;
color: #6c757d !important;
box-sizing: border-box;
border-collapse: collapse;
width: 100%;
margin-bottom: 1rem;
background-color: transparent;
border: 1px solid #dee2e6;
table-layout: fixed;
}
.timetable_event {
width: 100%;
line-height: normal;
}
<table class="table table-bordered table-responsive-sm" id="calendar">
<thead>
<tr>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
<th>Sun</th>
</tr>
</thead>
<tbody id="calendar-body">
<tr>
<td></td>
<td></td>
<td></td>
<td>1
<div class="timetable_event">
<small>Subject: [00000111] AUDICION Y LENGUAJE / LOGOPEDIA</small>
<br>
<small>From: 02:00</small>
<br>
<small>To: 05:33</small>
<br>
</div>
</td>
<!--more code -->
</tbody>
</table>
有什么建议吗?
感谢阅读!
【问题讨论】:
-
是要缩小文字还是要剪掉?
-
我需要使文本更小(取决于它的长度)并让单元格具有固定大小。 @connexo
-
您无法固定单元格高度,请参阅下面的答案。要根据内容长度减小字体大小,您需要使用 Javascript。
-
您是否尝试在
vw中设置font-size?
标签: jquery html css html-table