网站应具有与视频相同的背景颜色 [英] Website should have same background color as video

查看:260
本文介绍了网站应具有与视频相同的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,有一个HTML5视频。网站应该具有与视频相同的背景颜色,因此我已将网站的背景设置为与视频相同的HEX代码。这在Chrome看起来不错,但在Safari视频有一个其他背景颜色作为网站,这看起来丑陋。我能做什么?谢谢!

I have a website, with a HTML5-video. The website should have the same background color as the video, so I have set the website's background to the same HEX-Code as the video's. This looks fine in Chrome, but in Safari the video has a other background color as the website, which looks ugly. What can I do? Thanks!

Chrome的屏幕截图,应该是

Screenshot from Chrome, as it should be

Safari的屏幕截图,因为它不应该是

Screenshot from Safari, as it shouldn't be

推荐答案

请尝试以下操作:

function BrowserDetection() {
    if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
                     $(body).css("background-color":"grey");   
                    }
    }

你可以找到正确的颜色HEX-确保这行是你的.js文件中的最后一行,并确保你的.js文件被加载到你的.css文件之后,以便鳕鱼覆盖你的CSS如果浏览器是safari

You can probably find the right color HEX-Code, make sure this line is the last in line in your .js file and make your sure your .js file is loaded in after your .css file so that the cod overwrites your css if the browser is safari

来源: http: //forums.asp.net/t/1965754.aspx?Determine+the+browser+using+Javascript+JQuery

如果上面的代码不' t工作以下可能:

if the code above doesn't work the following may:

if ( $.browser.webkit ) {
    $(body).css("background-color":"grey"); 
  }

但是上面的代码在jquery 1.9及以上版本中已弃用。

however the code above is deprecated in jquery 1.9 and above.

这篇关于网站应具有与视频相同的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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