Is it possible to have a border around an image which is a lin开发者_运维百科k via CSS, so that when I hover over the image a border appears around the image? I would like a 5px thick border around every image which is a link, yet I'm not able to get it done quickly :( Any help would be greatly appreciated.
If you don't want the content to jump around, you would want to make room for the border when the images are not hovered:
a img { padding: 5px; }
Then replace the padding with border:
a:hover img { padding: 0; border: 5px solid red; }
You can also use transparent border, and then set a color: a img { border: 5px solid transparent; }
and: a:hover img { border: 5px solid red; }
.
精彩评论