简体   繁体   English

如何获得图像周围的边界

[英]How to get border around image

Hi there I'am playing around with light box. 嗨,我在玩灯箱。 What I am trying to do is get a border around my thumbnail so that when the user hovers over it, it will change color. 我正在尝试做的是在缩略图周围添加边框,以便当用户将鼠标悬停在其上方时,它将改变颜色。

Example : http://lokeshdhakar.com/projects/lightbox2/ 范例: http : //lokeshdhakar.com/projects/lightbox2/

You can see when you hover the thumbnail it changes the border color around the image. 当您将鼠标悬停在缩略图上时,您会看到它更改了图像周围的边框颜色。 Can anyone help me do this with my images? 有人可以帮我做这些吗? I have put them around in a div and i got 6 of them. 我把它们放在一个div中,我得到了6个。 Thanks for the help. 谢谢您的帮助。

Html: HTML:

<div class = "lightbox">
    <a href="images/image1.jpg" rel="lightbox[group]"><img src="images/image1t.jpg" /></a>
    <a href="images/image2.jpg" rel="lightbox[group]"><img src="images/image2t.jpg" /></a>
    <a href="images/image3.jpg" rel="lightbox[group]"><img src="images/image3t.jpg" /></a>
    <a href="images/image4.jpg" rel="lightbox[group]"><img src="images/image4t.jpg" /></a>
    <a href="images/image5.jpg" rel="lightbox[group]"><img src="images/image5t.jpg" /></a>
    <a href="images/image6.jpg" rel="lightbox[group]"><img src="images/image6t.jpg" /></a>
</div>

try something like this 尝试这样的事情

a img
{
border:3px solid #ccc;
}
a:hover img
{
border:3px solid #666;
}

for better example check this fiddle 更好的例子检查这个小提琴

You don't need a border, just add some padding and a background-color to the anchor. 您不需要边框,只需在锚点上添加一些paddingbackground-color即可。 Then change it's color on :hover 然后在:hover上更改它的颜色

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM