问题描述
我将如何使用 CSS 和 HTML 来实现类似于本网站的作品集页面 Solid Giant 上的效果?
How would I go about acheiving an effect similar to that on this site's portfolio page Solid Giant, with CSS and HTML?
我原以为只要放这样的东西就可以了:
I had thought that just putting something like this would work:
a img{
margin-top: 5px;
}
a img:hover{
margin-top: 0px;
}
但它不起作用,即使我将 :hover 放在链接上而不是 img 上.我搜索了他的代码和css,但我一生都无法弄清楚这一点.请帮忙:)
But it did not work, even if I put the :hover on the link instead of the img. I scoured his code and css but I could not for the life of me figure this out. Help please :)
推荐答案
position: relative 可以:
a img:hover{ position: relative;
top: -5px;}
请注意,position: relative 保留文档流中的空间,就好像元素没有被 移动一样.但我认为在这种情况下,这不是问题.
note that position: relative reserves the space in the document flow as if the element were not moved. But I think in this case, that is not an issue.
这篇关于悬停时将链接图像向上移动 5px的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)