
css 布局冲突:display 与 float
问题:
为何设置 display: 'flex', alignItems: 'center' 后,子标签不能正常浮动了?
其中一段代码:
<div style={{
textAlign: 'left',
height: '40px',
display: 'flex',
alignItems: 'center'
}}>
<label style={{float: 'left'}}>{props.title}</label>
<input style={{float: 'right'}} placeholder='搜索:'>
</div>答案:
float 和 flex 布局是两种不同的概念,无法同时生效。
解决方法:
以上就是设置 display: flex 和 float: left/right 后,子标签为何不能正常浮动?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号