用CSS控制不同类型链接的显示
用CSS区分内外链接是我花了点力气才实现的,放到这里留个底,供自己和其他有此需要的站长和博客主参考。
最初的目的是用css区分内外链接,给外链增加一个相应的图标
后来发展为论坛、百科等也分出来了==
不过图标制作不能,跟fz捣鼓不出什么结果,还是请jk出山了==
/* links */
a
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_popup.gif) no-repeat right top;
padding-right:14px;
}
这一步是给所有的链接都加一个图标指示
下面就来把内链分出去
a[href^="http://www.gmly.info"]
{
background-image:none;
padding-right:0px;
}
照此思路,分站的链接也可以区分出来
a[href^="http://wiki.gmly.info"]
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_wiki.gif) no-repeat right top;
padding-right:14px;
}
a[href^="http://bbs.gmly.info"]
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_smf.gif) no-repeat right top;
padding-right:14px;
}
a[href^="http://trle.gmly.info"]
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_trle.gif) no-repeat right top;
padding-right:14px;
}
如果模板里用到了其他链接,也需要区分出来,否则也会带上外链图标,显然会影响效果。
提取它们的语法和上面也是一样的,例如:
a[href^="http://feed.gmly.info"]
{
background-image:none;
padding-right:0px;
}
a[href^="http://countt.51yes.com"]
{
background-image:none;
padding-right:0px;
}
a[href^="http://creativecommons.org"]
{
background-image:none;
padding-right:0px;
}
a[href^="http://wordpress.org"]
{
background-image:none;
padding-right:0px;
}
还有个问题就是,如果页面中使用了锚链接,则也会出现外链图标。
锚链接的html代码和上面的不同。
设锚(例如“返回页顶”的锚):<a name="top">
链接(例如“返回页顶”链接):<a href="#top">
要把它们“提取”出来,格式则是:
a[name]
{
background-image:none;
padding-right:0px;
}
a[href^="#"]
{
background-image:none;
padding-right:0px;
}
最初的目的是用css区分内外链接,给外链增加一个相应的图标
后来发展为论坛、百科等也分出来了==
不过图标制作不能,跟fz捣鼓不出什么结果,还是请jk出山了==
/* links */
a
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_popup.gif) no-repeat right top;
padding-right:14px;
}
这一步是给所有的链接都加一个图标指示
下面就来把内链分出去
a[href^="http://www.gmly.info"]
{
background-image:none;
padding-right:0px;
}
照此思路,分站的链接也可以区分出来
a[href^="http://wiki.gmly.info"]
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_wiki.gif) no-repeat right top;
padding-right:14px;
}
a[href^="http://bbs.gmly.info"]
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_smf.gif) no-repeat right top;
padding-right:14px;
}
a[href^="http://trle.gmly.info"]
{
background:url(http://www.gmly.info/wp-content/themes/Quarx/images/icon_trle.gif) no-repeat right top;
padding-right:14px;
}
如果模板里用到了其他链接,也需要区分出来,否则也会带上外链图标,显然会影响效果。
提取它们的语法和上面也是一样的,例如:
a[href^="http://feed.gmly.info"]
{
background-image:none;
padding-right:0px;
}
a[href^="http://countt.51yes.com"]
{
background-image:none;
padding-right:0px;
}
a[href^="http://creativecommons.org"]
{
background-image:none;
padding-right:0px;
}
a[href^="http://wordpress.org"]
{
background-image:none;
padding-right:0px;
}
还有个问题就是,如果页面中使用了锚链接,则也会出现外链图标。
锚链接的html代码和上面的不同。
设锚(例如“返回页顶”的锚):<a name="top">
链接(例如“返回页顶”链接):<a href="#top">
要把它们“提取”出来,格式则是:
a[name]
{
background-image:none;
padding-right:0px;
}
a[href^="#"]
{
background-image:none;
padding-right:0px;
}

