根据浏览器分别应用不同的CSS

本文介绍如何为IE6浏览器单独设置CSS样式,并提供了一种利用条件注释实现的方法。此外,还探讨了使用JavaScript按浏览器类型应用不同CSS文件的技术。针对滚动新闻链接的问题,给出了具体的<marquee>标签用法,解决了链接悬浮时的问题。
问:

I want to write some css that works only in IE6 without putting it in a separate file like the following:


<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="iespecific.css" />
<![endif]-->

 Is this possible?

Also if some one know any articles about how to make a scrolling news links without having problems in hovering as I have for example : news1..news2..news3 also the dots shouldn't be clickable like the links as mine too.Please lead me to it.


答:

For more information about Conditional comments, check the following link please:
 
CSS - Conditional comments
http://www.quirksmode.org/css/condcom.html
 
Otherwise, there is another way to apply CSS by browser type and resolution ratio via JavaScript:
Code from http://blog.youkuaiyun.com/xiaozhao_19/archive/2008/03/25/2216414.aspx
 
 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
if (window.navigator.userAgent.indexOf("MSIE")>=1

//IE 
setActiveStyleSheet("default.css"); 
}
else
if (window.navigator.userAgent.indexOf("Firefox")>=1

//Firefox 
setActiveStyleSheet("default2.css"); 
}
else
//other
setActiveStyleSheet("newsky.css"); 
}
 
}
 

function setActiveStyleSheet(title)
document.getElementsByTagName(
"link")[0].href="style/"+title; 
}
 
//--> 
</SCRIPT>  
 
 
To make scrolling news links, I think you can use a <marqueue> just like the following code: 

 
< marquee  behavior =scroll  direction =left  width =100%  height =115  scrollamount =1  scrolldelay =70  onmouseover ='this.stop()'  onmouseout ='this.start()' >    
< href ="http://forums.asp.net" > your links </ a >
< href ="http://forums.asp.net" > your links </ a >
< href ="http://forums.asp.net" > your links </ a >
< href ="http://forums.asp.net" > your links </ a >
< href ="http://forums.asp.net" > your links </ a >
</ marguee >
 
 
If I’ve misunderstood your problem, please feel free to let me know.
 
Thanks.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值