可以在CSS中使用多种链接样式吗? [英] Is it possible to use multiple link styles in css?

查看:107
本文介绍了可以在CSS中使用多种链接样式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能吗?我在Google各处浏览,找不到所需的答案。
这里的问题是:
是否可以像说div标题中的文本具有红色悬停,而div中的页脚中的文本具有白色悬停?



或者这是否不可能,您只能为整个文档设置1种样式吗?



我希望我对它的解释很好。 / p>

预先感谢!

解决方案

这很有可能,就像其他任何元素一样,您可以通过更具体地设置样式来分别设置样式。



如果您有以下HTML:

 < div id = top> ; 
< a href =#>第一个链接< / a>
< / div>

< div id = bot>
< a href =#>第二链接< / a>
< / div>

使用此CSS,您可以设置两个链接的样式:

  a:hover {
color:#000;
}

使用此CSS,您可以分别设置样式:

  #top a:hover {
color:#f00;
}

#bot a:hover {
color:#fff;
}


Is this possible? I've looked all over google and can't find the answer i'm looking for. Here the question: Is it possible like lets say the text in the div header has a red hover, and the text in the div in the footer a white hover?

Or is this just not possible and can you only set 1 style for the whole document?

I hope i'm explained it well.

Thanks in advance!

解决方案

This is very much possible, just like any other element you can style them separately by being more specific.

If you have this HTML:

<div id="top">
    <a href="#">First link</a>
</div>

<div id="bot">
    <a href="#">Second link</a>
</div>

With this CSS you would style both links:

a:hover {
    color: #000;
}

With this CSS you can style them separately:

#top a:hover {
    color: #f00;
}

#bot a:hover {
    color: #fff;
}

这篇关于可以在CSS中使用多种链接样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆