2012-02-03 48 views

回答

2

看看这个布局。另请注意,ID应该是唯一的。您多次使用图像缩略图。

现场演示:http://jsfiddle.net/9C72X/

HTML

<div> 
    <div class="image-thumb"> 
    <img src="http://www.javeacasas.com/images/javea-property.jpg"> 
    <p class="property-title">Land for Sale</p> 
    </div> 

    <div class="image-thumb"> 
    <img src="http://in.all.biz/img/in/service_catalog/15784.jpeg"> 
    <p class="property-title">Sale at Mura, Puttur</p> 
    </div> 
</div> 

CSS

.image-thumb { 
    display: inline-block; 
    vertical-align: top; /* <-- update to solve multiline text */ 
    width: 200px; 
} 

.image-thumb img { 
    width: 100%; 
} 

.property-title { 
    text-align: center; 
    font-size: 10px; 
} 
+0

检查更新的提琴.. http://jsfiddle.net/9C72X/1/,我正面临以下问题。当财产标题变为2行时,布局将错位 – 2012-02-03 12:51:37

+0

您可以通过在'image-thumb'中添加'vertical-align:top'来解决此问题。我会更新我的答案。 – Bazzz 2012-02-03 13:17:15

0

个人而言,我不认为你需要绝对定位的标题。

你也可以考虑使用不同的标记。

<figure class="image-thumb"> 
    <img class="imgthumg"> 
    <figcaption class="property-title"> 
     image title 
    </figcaption> 
</figure> 

试试这个,左边的浮动导致您的图像拇指容器崩溃。

.img-thumb { 
    position: relative; 
    padding-left: 5px; 
    word-spacing: 10px; 
    float: left; 
} 

.imgthumb { 
    width:230px; 
    height:161px; 
    background:#FFF; 
    border:1px solid #909090; 
    margin-left:10px; 
    margin-bottom: 30px; 
} 

.property-title { 
    bottom: 0; 
    font-family: 'Verdana'; 
    font-size: 8pt; 
    margin-left: 10px; 
    margin-top: 10px; 
    width: 236px; 
    position: absolute; 
} 
+0

我添加了图片以便更好地理解,请再次检查问题 – 2012-02-03 12:16:28

0

下面一个这些CSS类替换为:

#image-thumb 
{ 
padding-left: 5px; 
word-spacing: 10px; 
float:left; 
} 

.imgthumb 
{ 
    width:230px; 
    height:161px; 

    position:relative; 
    background:#FFF; 
    border:1px solid #909090; 
    margin-left:10px; 

    } 

.property-title 
{ 

font-family: 'Verdana'; 
font-size: 8pt; 
margin-left: 10px; 
margin-top: 0; 
position: relative; 
width: 236px; 
} 

http://jsfiddle.net/abhinavpratap/3V6MM/4/