2016-04-14 94 views
-4

在HTML: 我怎么能做出不同的图片,里面<div>超链接插入DIV

其各自的超链接在一起,我想避免许多<div>条目为每个图像。

<div class="image_" data-no-elementresizer><a href="http://....." target="_self">img.jpg</a></div> 

<div class="image_" data-no-elementresizer><a href="http://....." target="_self">img.jpg</a></div> 

<div class="image_" data-no-elementresizer><a href="http://....." target="_self">img.jpg</a></div> 
+0

这很难想象你想在这里实现什么。 –

回答

1

这是你要找的东西吗?

.gallery { 
 
    width: 820px; 
 
    background-color: blue; 
 
    height: 800px; 
 
} 
 
.gallery img { 
 
    float: left; 
 
    vertical-align: top; 
 
    width: 200px; 
 
    height: 200px; 
 
}
<div class="gallery"> 
 
    <img src="http://lorempixel.com/200/200" /> 
 
    <img src="http://lorempixel.com/200/200/people/2" /> 
 
    <img src="http://lorempixel.com/200/200/city/3" /> 
 
    <img src="http://lorempixel.com/200/200/city/2" /> 
 
    <img src="http://lorempixel.com/200/200" /> 
 
    <img src="http://lorempixel.com/200/200" /> 
 
    <img src="http://lorempixel.com/200/200/people" /> 
 
    <img src="http://lorempixel.com/200/200/sports/2" /> 
 
    <img src="http://lorempixel.com/200/200/city" /> 
 
    <img src="http://lorempixel.com/200/200/sports" /> 
 
</div>

0

这可能会迟到,但在这里我的答案与图片和超链接。

div.image { 
    margin: 5px; 
    border: 1px solid #ccc; 
    float: left; 
    width: 180px; 
} 

div.image :hover { 
    border: 1px solid #777; 
} 

div.image img{ 
    width: 100%; 
    height: auto; 
} 


<div class="image"> 
    <a target="_self" href="Url"> 
    <img src="ImageUrl" width="300" height="200"> 
    </a> 
    <a target="_self" href="Url"> 
    <img src="ImageUrl" width="300" height="200"> 
    </a> <a target="_self" href="Url"> 
    <img src="ImageUrl" width="300" height="200"> 
    </a> 
</div> 
+0

谢谢!这正是我所期待的。它工作完美! – Ana

+0

与图像的位置有关系,要么将它们放在垂直行或两行中,我会在HTML还是CSS中编辑此方面的内容?再次感谢你! – Ana

+0

它很好,它帮助你所以你可以把它标记为**答案**。但我无法理解你的下一个问题。你想要图像垂直对齐吗? – Atula