【问题标题】:Making specific elements change position on hover使特定元素在悬停时改变位置
【发布时间】:2013-10-24 16:52:34
【问题描述】:

我无法写出令人满意的标题,因此它与我的主题无关。我想知道当我浏览它们时如何移动链接,但也不要移动其他链接。我试图放置不同的类,但我没有解决问题。 这里有一个例子。简而言之,当我浏览第一条推特时,我不希望第二条移动。

Fiddle

a#twitter{
    display:block;
    background:url(http://www.livefluid.com/img/twitter-sprite.png) no-repeat 0px 0px scroll;
    width:72px;
    height:28px;
    display: inline-block;  
    vertical-align: middle;  
    margin-right:10px;
    margin-top:0px;
}

a#twitter:hover{
    margin-top:20px;
    background-position:0px -28px;
}

【问题讨论】:

  • 你想不出一个好标题,所以写了一个完全不相关的标题?我把标题改成了希望更好的东西。原文是“使用 HTML 标记构建图像?”。

标签: javascript html css image hyperlink


【解决方案1】:

this fiddle

我已将您的链接和 CSS 更改为使用类而不是 id。

HTML

<a class="twitter" href='http://www.twitter.com'></a>
<a class="twitter" href='http://www.twitter.com'></a>

CSS

a.twitter {
    display:inline-block;
    background:url(http://www.livefluid.com/img/twitter-sprite.png) no-repeat 0px 0px scroll;
    width:72px;
    height:28px;
    display: inline-block;
    vertical-align: top;
    margin-right:10px;
    margin-top:0px;
}
a.twitter:hover {
    margin-top: 20px;
    background-position:0px -28px;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 2010-10-21
    • 1970-01-01
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-11
    相关资源
    最近更新 更多