html - 考虑溢出内容的大小进行定位
问题描述
是否有一种仅限 CSS/HTML 的方法来考虑溢出内容的大小?考虑下面的例子:
.outerZeroSize {
width: 0px;
height: 0px;
overflow: visible visible;
}
.innerContent {
width: 200px;
height: 300px;
}
.belowContent {
}
<div class="outerZeroSize">
<div class="innerContent">
Some content<br/>
Some more content <br/>
And some more
</div>
</div>
<div class="belowContent">Content below</div>
divbelowContent
中的文本最终位于innerContent
.
问题:由于height
ofinnerContent
是300px
,我想出belowContent
现在300px
下面outerZeroSize
(而不是在上面)。这对 CSS/HTML 可行吗?
约束:
- 假设它
.outerZeroSize
不能.innerContent
改变(既不是 HTML,也不是 CSS 部分),因为它们来自第三方(React-Virtualized Table)。 - 更新:的高度
.innerContent
可以动态变化,300px
这只是一个例子(所以仅仅抵消.belowContent
同样的数量也不是一种选择)。 - 可以改变的是
.belowContent
(HTML 和 CSS),当然也可以在div周围添加东西。.outerZeroSize
相关问题(从 React Virtualized Table 的角度来看)。
解决方案
只需在. _belowContent
.outerZeroSize {
width: 0px;
height: 0px;
overflow: visible visible;
}
.innerContent {
width: 200px;
height: 300px;
}
.belowContent {
margin-top: 300px;
}
<div class="outerZeroSize">
<div class="innerContent">
Some content<br/>
Some more content <br/>
And some more
</div>
</div>
<div class="belowContent">Content below</div>
另一种解决方案是搬进belowContent
去outerZeroSize
。
.outerZeroSize {
width: 0px;
height: 0px;
overflow: visible visible;
}
.innerContent {
width: 200px;
height: 300px;
}
.belowContent {
width: 200px;
}
<div class="outerZeroSize">
<div class="innerContent">
Some content<br/>
Some more content <br/>
And some more
</div>
<div class="belowContent">Content below</div>
</div>
推荐阅读
- java - 即使我使用 DB_CLOSE_DELAY=-1 报告 H2 内存数据库也找不到表
- opengl - 体积光未正确渲染体积
- java - 微服务连接Oracle数据库
- javascript - 使用 fetch 设置 localStorage
- vba - 运行时错误“-2145320854 (8021006a)”:访问图像属性时出现自动化错误
- amazon-web-services - ECS、负载均衡器和具有多个容器的任务定义问题
- php - 警告:第 67 行的非法字符串偏移量“testi_name”
- r - 通过设置特定的目标日期计算 R 中的行之间的差异
- amazon-eks - Fargate 将自动增加内存请求大约 200Mi
- python - Anaconda 无法修改 Python 版本