Css 一个分区内的中心分区
我寻找这个问题的答案已经很久了 我正在为一个新网站使用12列布局。我在一行有4个div:Css 一个分区内的中心分区,css,html,Css,Html,我寻找这个问题的答案已经很久了 我正在为一个新网站使用12列布局。我在一行有4个div: <div class="colContainer"> <div class="row"> <div class="threecolImg"> <p>Row 1: three</p> </div> <div cla
<div class="colContainer">
<div class="row">
<div class="threecolImg">
<p>Row 1: three</p>
</div>
<div class="threecolImg">
<p>Row 1: three</p>
</div>
<div class="threecolImg">
<p>Row 1: three</p>
</div>
<div class="threecolImg last">
<p>Row 1: three</p>
</div>
</div>
</div>
就目前情况而言,两个div都是相邻的(这很好!),但没有居中(这很糟糕!)
谁能帮我把它们放在中间吗
非常感谢,
保罗将你所有的三个colimg div换成三个col div。它们将居中
<div class="colContainer">
<div class="row">
<div class="threecol">
<p>Row 1: three</p>
</div>
<div class="threecol">
<p>Row 1: three</p>
</div>
<div class="threecol">
<p>Row 1: three</p>
</div>
<div class="threecol last">
<p>Row 1: three</p>
</div>
</div>
</div>
如果您想在三列div中设置图像样式,请选择该选择器:
.threecol img {
}
您使用的是一个名为“三列”的系统,但每行有四列,这有意义吗?你的意思是将外部容器放在页面中心吗?4个div在12列网格中是3列宽的感谢你的快速回答HighKick,但这似乎没有改变任何事情:(你能试着设置一个JSFIDLE吗?这里有一个:另外,你使用的是哪一个12列网格?自制的还是其他的?我使用这个网格:我也把这个页面上传到了我的网站:我想你应该改变你的HTML,因为你创建了一个CSS类,不必要地试图模仿现有的CSS类。
.threecolImg {
float: left;
min-height: 1px;
width: 22.05%;
}
.threecol img {
}