html - 如何防止 display:flex 项目清除先前的浮动?
问题描述
看起来像 display:flex 项目自动清除以前的浮动。
如何防止它被清除?(我需要之前的内容与 flex 容器重叠)。
例如:
.floater{
float:right;
width: 200px;
border:1px solid red;
}
.row{
display:flex;
border:1px solid green;
padding:12px;
width:100%;
clear:none;
}
.col-400{
flex-basis:400px;
border:1px solid blue;
padding:12px;
}
.col-grow{
flex-grow:1;
border:1px solid teal;
padding:12px;
}
<div class='outer'>
Intro content
<div class='floater'>
Please float to right. And don't clear.
Please float to right. And don't clear.
Please float to right. And don't clear.
</div>
<div class='row'>
<div class='col-400'>
Left col
Left col
Left col
Left col
Left col
</div>
<div class='col-grow'>
Main col
Main col
Main col
Main col
Main col
Main col
Main col
Main col
Main col
Main col
</div>
</div>
</div>
我希望红色与绿色重叠。
解决方案
利用position: absolute;
.floater{
position: absolute;
float:right;
width: 200px;
border:1px solid red;
}
推荐阅读
- aws-lambda - 使用无服务器是否可以实现私有 HTTP 事件?
- node.js - SyntaxError:无效的正则表达式:在 Next.js 的首次安装和运行期间反应
- python - .pip 配置了需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用。(视窗 10)
- node.js - 从回调返回外部变量不起作用
- laravel - 如何使用 CSS 颜色改进刀片中的代码?
- javascript - 幻灯片边框不需要的填充
- c# - 西里尔符号显示为象形文字,httpContext.Response.WriteAsync("")
- php - 如何编写一个函数来替换街道名称
- c# - 如何使用水粒子系统扑灭火粒子系统?
- r - 以简洁的方式显示几个代码块