ie样式表没有加载_IE中的用户样式表

ie样式表没有加载

ie样式表没有加载

Let's say you want to quickly try out some small stylesheet changes, but you don't want to (or prefer not to, or for some reason temporarily you just can't) modify your application's CSS file(s). In FF it's easy - you have Firebug and you can play with styles until blue in the face. And in case you do get blue in the face and start making so many changes that you get lost, you can create a new clean and tidy CSS file, place it on your hard drive and use Web Developer extension to load it (Menu CSS->Add User Style Sheet). With WebDev Extension you can also Edit CSS right there, although unfortunatelly it's not always working when you have frames.

假设您想快速尝试一些小的样式表更改,但又不想(或不想这样做,或者由于某种原因暂时不能)修改应用程序CSS文件。 在FF中,这很容易-您拥有Firebug,并且可以使用各种样式进行播放,直到脸部变成蓝色为止。 万一您脸色发青并且开始进行大量更改而丢失,可以创建一个新的整洁CSS文件,将其放在硬盘上,然后使用Web Developer扩展程序进行加载(菜单CSS- >添加用户样式表)。 使用WebDev Extension,您也可以在此处编辑CSS,尽管不幸的是,当您拥有框架时,它并不总是有效。

OK, there are options for Firefox. But how about IE?

好的,有Firefox的选项。 但是IE呢?

In IE you have IE Developer Toolbar, definitelly helpful, but you can only modify element styles, not the stylesheet rules. So? A tiny little bookmarklet to the rescue!

在IE中,您可以使用IE Developer Toolbar,它绝对有帮助,但是您只能修改元素样式,而不能修改样式表规则。 所以? 救援的小书签!

My bookmarklet assumes you have a file called C:\user.css and loads this stylesheet on demand in your page, in every frame, just in case you use frames. Simple, yet useful, I hope. Here's the (readable) code:

我的小书签假设您有一个名为C:\user.css的文件,并在每个框架中按需加载此样式表,以防万一您使用框架。 我希望简单但有用。 这是(可读的)代码:

javascript:
var css_file = prompt('Which CSS file you want to load today?','c:/user.css');
function addcss(w) {
    var html_doc = w.document.getElementsByTagName('head')[0];
    var css = w.document.createElement('link');
    css.setAttribute('rel', 'stylesheet');
    css.setAttribute('type', 'text/css');
    css.setAttribute('href', css_file);
    html_doc.appendChild(css);
}
var errors = 0;
function checkFrames(w) {
  if(w.frames && w.frames.length>0){
    for(var i=0;i<w.frames.length;i++){
      var fr=w.frames[i];
      try {
        addcss(fr);
      } catch (e) {
        errors++;
      }
      checkFrames(fr);
    }
  }
}
checkFrames(window);
addcss(window);
if (errors > 0) {
    alert('Could not access ' + errors + ' frame(s)');
}

安装并玩转 (To install and play around)

Right-click this link and add it to your favourites:

右键单击此链接并将其添加到您的收藏夹:

Add User StyleSheet 添加用户样式表

Have in mind that this is IE-only (tested IE7). I don't think FF will allow you to access files on your local drive like this. But for FF you have the tools to do this anyway.

请记住,这仅适用于IE(已测试IE7)。 我认为FF不会允许您像这样访问本地驱动器上的文件。 但是对于FF,您仍然拥有执行此操作的工具。

Another option to load local stylesheets in IE is to use the user CSS capability built in the browser, you can find it under Tools/Internet Options/Accessibility, but this will load your user CSS first (as opposed to last as the case is with my bookmarklet), so the "real" style definitions will overwrite yours, unless you always use !important and the "real" styles don't.

在IE中加载本地样式表的另一种选择是使用浏览器中内置的用户CSS功能,您可以在“工具/ Internet选项/可访问性”下找到它,但这将首先加载您的用户CSS(与之相反,最后加载该用户CSS)我的书签),因此除非您始终使用!important而不使用“真实”样式,否则“真实”样式定义将覆盖您的定义。

谢谢! (Thanks!)

Have fun with the custom CSS and let me know how you find it.

尝试使用自定义CSS,让我知道如何找到它。

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/user-stylesheet-in-ie/

ie样式表没有加载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值