html - 为什么这段代码会导致 div 并排而不是垂直列?
问题描述
我试图在页面右侧浮动两个 div 以便它们堆叠:
<div style=" float: right;">
<div style="padding: 10px; background-color: #2835d0;; color: white; border-radius: 10px;">
test1
</div>
</div>
<div style=" float: right;">
<div style="padding: 10px; background-color: #2835d0;; color: white; border-radius: 10px;">
test2
</div>
</div>
解决方案
你是这个意思吗?
.text-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
}
<div class="text-container">
<div>
<div style="padding: 10px; background-color: #2835d0;; color: white; border-radius: 10px;">
test1
</div>
</div>
<div>
<div style="padding: 10px; background-color: #2835d0;; color: white; border-radius: 10px;">
test2
</div>
</div>
</div>
推荐阅读
- date - 在 DB2 中使用日期的正确语法是什么?
- linq - Roslyn 分析器:Linq 中的可空注释
- mysql - SQL - 加入两个表和 COUNT(也是 NULL 值)
- html - 为什么蒙版图像会忽略 z-index?
- javascript - 重新格式化数组
- postgresql - 我可以使用一行代码告诉 Datagrip 转储输出吗?
- javascript - 在 Web 浏览器的 JavaScript 中处理异步事件处理程序中的错误
- jboss - 将 jboss 版本 6.4 迁移到 7.2 时出现异常
- delphi - 我应该使用什么结构?德尔福 10.3
- unity3d - Unity3D中的按钮没有响应