【发布时间】:2020-08-22 23:27:33
【问题描述】:
我正在努力将 div 放在第三个 td 下(屏幕上 7 下 6)。 div(7) 还应根据 td(6) 高度更改其 Y 位置。
1、2、4、5、7 动态改变其内容(它可以包含<sub> 和<sup> 标签)并且文本(6)应该与4 和5 框的顶部对齐。
如果 6 为空,则 7 应位于 4 和 5 框顶部对齐的 6 位。框的宽度和高度应与屏幕上的完全相同(4 - ~width: 200px;, 5 - ~width: 120px;)。
- 我试图将那个 div 放在表格中,但它使盒子变大了。
- 我还尝试在 6 元素的 tr 内制作表格,这也使盒子难看。
- 当你给表格
position absolute时,div 不会改变它的位置。
这是一项复杂的任务,我一周都无法完成。我还尝试制作rowspan 和第三个 tr,将 7 置于 6 之下,但 rowspan 也使框变大(like it shown here)。
允许更改html代码。通过 CSS 制作它很重要,因为它需要打印。当你尝试用 JS 解决它时,最大的问题之一是当你缩小一个窗口时,项目可以改变它的位置。
.detailName {
margin-top: 10px;
}
.table-sources {
width: 400px;
margin-left: 40px;
margin-top: 3px;
}
.table-wrap:first-child {
margin-top: -10px;
}
.table-wrap {
display: flex;
}
.table-vals {
margin-bottom: 5px;
}
.table-vals th {
max-width: 200px;
text-align: left;
font-size: 13px !important;
font-weight: normal;
vertical-align: top;
}
.table-vals .first-th {
min-width: 200px;
}
.table-vals td {
text-align: center;
padding: 10px;
font-size: 20px;
font-weight: bold;
}
.table-vals .second-th {
float: left;
position: relative;
left: 15px;
width: 98px;
}
.table-vals .first-td {
border: 2px solid #192E7B;
}
.table-vals .second-td {
position: relative;
left: 15px;
background: wheat;
}
.table-vals .third-th {
position: relative;
left: 40px;
}
.table-vals .third-td {
font-size: 14px;
font-weight: normal;
position: relative;
left: 30px;
top: -20px;
text-align: left;
}
.source-link {
word-break: break-word;
font-size: 12px;
color: grey;
position: absolute;
width: 400px;
}
.detailName {
display: block;
}
.detailName {
font-weight: bold;
}
<div class="tables-wrap">
<div class="table-wrap">
<table class="table-vals">
<tbody>
<tr class="first-tr">
<th class="first-th">ipsum dolor</th>
<th class="second-th">ipsum dolor</th>
<th class="third-th">ipsum</th>
</tr>
<tr class="second-tr">
<td class="first-td">ipsum dolor</td>
<td class="second-td" style="background:rgb(123, 161, 196);color:white;">ipsum dolor</td>
<td class="third-td" style="/* top:-23px; */">Norddeutsches Tiefland</td>
</tr>
</tbody>
</table>
<div class="table-sources" style="position: relative; left: -120px; top: 31px;">
<span class="detailName">Ipsum dolor</span><span class="source-link">Ipsum dolor Ipsum dolor Ipsum dolor Ipsum dolor Ipsum dolor Ipsum dolor Ipsum dolor Ipsum dolor</span>
</div>
</div>
</div>
【问题讨论】:
-
你在外面使用 7th div 的原因是什么?它可以在
td下一个低于 6th div
标签: javascript html css