css - CSS:如何将一个 div 移到另一个上方?
问题描述
我有两个 div,A 和 B。我想使用 CSS 将元素 B 放在元素 A 之上。如果需要,我可以在父 div 中扭曲它们。我尝试了几件事(浮动,垂直对齐),但没有成功。
我有的:
一个
乙
我想要的是:
乙
一个
任何想法?谢谢
解决方案
用容器中的 2 个文本 div 试试这个
body {
font: 400 16px/1.5 sans-serif;
}
.text-wrap {
position: relative;
}
.text-1 {
position: absolute;
top: 1.5em; /* same as line-height */
}
.text-2 {
position: absolute;
top: 0;
}
<div class="text-wrap">
<div class="text-1">
AAA
</div>
<div class="text-2">
BBB
</div>
</div>
推荐阅读
- .net - @Html.AntiForgeryToken() 响应中缺少 RequestVerificationToken set-cookie 标头
- tensorflow - 如何提高目标检测的准确性,主要跟踪人工智能的计算机视觉应用到工业部署规模?
- azure-data-explorer - 删除 95% 的最高计数 Kusto Query
- python - 合并多个嵌套字典
- ios - 如何在 Swift 中自动触发后台代码?
- java - 在哪里可以找到“库”文件夹 (Netbeans JAR)
- java - 如何确保返回指定类型的列表?
- python - 时钟类错误处理的最佳方法?
- haskell - Haskell 中的类型重用
- .net - ComInterfaceType.InterfaceIsIDispatch,早期绑定和VB6