html - 如何修复:2 DIV 左浮动不工作
问题描述
我有主要的部门:面板主体和内部部门:包我的包在面板主体内正确显示,它们成排堆叠。
这是现场网站:https ://royalkingdom.net/store/?cat=1
我已经尝试添加到我的包裹中:float:left;
但是当我这样做时,包裹不会进入身体。
如果我删除float:left;
它,但它们不是每行 3 个
我的包css:
.package {
width: 33.33333333%;
}
我的面板主体 css:
.panel {
margin-bottom: 30px;
background: url(https://castiamc.com/buycraft/bordersv2/Middle.png);
width: 850px;
border: none;
border-radius: 0;
position: relative;
min-height: 300px;
padding: 20px;
color: #fff;
}
.panel-body {
padding: 15px;
text-align:justify;
}
.panel .panel-body {
color: #3d3e3f;
box-sizing: border-box;
position: relative;
max-width: 750px;
top: -75px;
left: 13px;
}
<div class="package">
<img src="'.(isset($image) && $image!="" && ($it == 1 || $it == 3 || $it == IMG_JPEG) ? $image : "img/404.jpg").'" class="img-rounded img-responsive" style="width:250px; height:168px;">
</div>
我希望在面板主体内每行显示 3 个包。
解决方案
在包的父级上,添加一个名为clearfix
并在样式表中定义此类的附加类:
.clearfix:after {
content: " ";
display: block;
clear: both;
}
基本上,浮动将元素从父级的自然流动中取出,因此添加这个“强制”它回到它的“正常”大小。
推荐阅读
- javascript - 尝试构建原型 - 出错
- bash - Systemctl 不运行在 bash 中完美执行的命令(反引号)
- linux - 问题您的 CPU 支持未编译此 TensorFlow 二进制文件以使用的指令:AVX2 FMA
- cobol - 如何使用 Cobol Screens 显示可滚动列表
- bootstrap-4 - 订阅 ngx-boostrap 模式
- c++ - boost::spirit::qi 解析器中的空行解析和错误检测
- sql-server-2008 - MS SQL Server 锁定列 X = y 的所有记录
- c# - 在构造函数中初始化时,自动属性的协变返回类型保持为空
- extjs - ExtJS TreePanel / TreeStore remoteSort 属性不覆盖前端排序
- sql-server - 与 Visual Studio 的 SQL Server Data Tools (SSDT) 进行比较,表相同时存在差异