gpt4 book ai didi

html - 当它在表格内时突出显示整个 div

转载 作者:太空宇宙 更新时间:2023-11-04 07:39:22 24 4
gpt4 key购买 nike

我试图突出显示表格内的一个 div 部分,但它似乎仅限于表格的宽度。滚动后的部分未突出显示。

我可以在 div 中添加样式,例如:“width:400px !important”,但我事先不知道宽度是多少。

有什么简单的解决方法吗?

.area1{
border:1px solid;
height:200px;
overflow:scroll;
float: left;
font-size: 16px;
}
.area1Content{
height:500px;
font-size: 16px;
white-space:nowrap;
}
 <div id="area1Id" class="area1">
<table>
<tr>
<td style="min-width:300px; max-width:300px"><div id="area1ContentId" class="area1Content">
<div style="BACKGROUND-COLOR:cyan;">Test long text sentence that will exceed the box width. I want that all the sentence will be highlighed</div>
</div>
</td>
</tr>
</table>
</div>

最佳答案

您可以通过将 inline-block 添加到 .area1Content 来实现您想要做的事情:

.area1{
border:1px solid;
height:200px;
overflow:scroll;
float: left;
font-size: 16px;
}
.area1Content{
height:500px;
font-size: 16px;
white-space:nowrap;
display: inline-block;
}
 <div id="area1Id" class="area1">
<table>
<tr>
<td style="min-width:300px; max-width:300px"><div id="area1ContentId" class="area1Content">
<div style="BACKGROUND-COLOR:cyan;">Test long text sentence that will exceed the box width. I want that all the sentence will be highlighed</div>
</div>
</td>
</tr>
</table>
</div>

关于html - 当它在表格内时突出显示整个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48660090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com