【发布时间】:2013-03-29 19:51:24
【问题描述】:
CSS
.contain {
max-width:960px;
text-align:center;
}
.category {
position:relative;
display: inline-block;
float:left;
padding:10px;
}
.category2 {
position:relative;
display: inline-block;
pading:10px;
}
.category3 {
position:relative;
display: inline-block;
float:right;
margin-right:50%;
padding:10px;
}
HTML
<div align="center" class="category">
<img src="gemstoneshomebutton.png" />
</div>
<div align="center" class="category2">
<img src="dichroichomebutton.png" />
</div>
<div align="center" class="category3">
<img src="filigreehomebutton.png" />
</div>
我正在尝试在容器 div 内对齐 3 个 309 像素宽、111 像素高的图像, 并且它们没有对齐中心,并且第三个图像跳到其他两个图像下方。 我尝试调整容器和 3 个 div 的宽度,我尝试了表格并更改了实际 html 的宽度,但没有成功。
这是我第一次使用 div,我认为它们会更容易,也许在分配宽度时我的数学是错误的,或者我只是把它的结构都错了。![这是我正在尝试的一个例子来实现,图中的三个类在这里。]http://i49.tinypic.com/2r2uqso.jpg
任何 我们将不胜感激。
【问题讨论】:
-
将
float: left放在所有三个上。还可以观看一些关于 CSS-Tricks 的截屏视频,它们会让你的学习过程更轻松 :) -
非常感谢,虽然我只是这样做了,它所做的只是在前两个 div/图像之间放置空间。
-
'Inspect Element' 是你的朋友,用它来解决定位问题。我的猜测是你可能需要调整宽度,并摆脱那个边距。同样重要的是要知道浮动元素会使
display属性无关紧要。 -
align属性为deprecated in HTML4.1 和not supported in HTML5。
标签: css image html positioning center